The writer of one kind of master data — named by #[MasterData(loader: …)] on the module that owns the data. The
loading command reads the file, checks every record and hands over the records as objects of the record class; the
writer knows its models and writes them. It inserts only: a record whose key the database already holds is kept as
it is.
final readonly class PartnersLoader implements MasterDataInterface
{
public function exists(string $key): bool
{
return Partner::query()->where('ext_ref', $key)->exists();
}
public function difference(object $record): ?array { … }
public function insert(array $records, BusinessTransaction $transaction): void
{
foreach ($records as $record) {
Partner::create([…]);
}
}
}
| Methods | ||
|---|---|---|
public
|
exists(string $key): bool
|
# |
public
|
difference(object $record): array<string, array{file: mixed, database: mixed}>|null
|
# |
public
|
insert(list<object> $records, BusinessTransaction $transaction): void
|
# |