Feature: Creating product import resolvers, wiring import job

This commit is contained in:
2026-07-09 00:37:14 +03:00
parent 825ce885c0
commit df03866285
16 changed files with 745 additions and 1 deletions
@@ -0,0 +1,41 @@
<?php
namespace Modules\Core\MigrateImport\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class ImportMapping extends Model
{
protected $guarded = [];
public function model(): MorphTo
{
return $this->morphTo();
}
public static function resolve(string $source, string $sourceType, string $externalId): ?Model
{
return static::query()
->where('source', $source)
->where('source_type', $sourceType)
->where('external_id', $externalId)
->first()
?->model;
}
public static function record(string $source, string $sourceType, string $externalId, Model $model): self
{
return static::query()->updateOrCreate(
[
'source' => $source,
'source_type' => $sourceType,
'external_id' => $externalId,
],
[
'model_type' => $model->getMorphClass(),
'model_id' => $model->getKey(),
],
);
}
}