| Methods |
public
|
from(Model $source): $this
Set model from which to copy records.
Set model from which to copy records.
|
#
|
public
|
to(Model $destination): $this
Set model in which to copy records into.
Set model in which to copy records into.
|
#
|
public
|
with(array<int, string>|array<string, array<mixed>> $references): $this
Set references to copy.
|
#
|
public
|
excluding(array<int, string>|array<string, array<mixed>> $exclusions): $this
Specifies which fields shouldn't be copied. May also contain arrays
for related entries.
->excluding(['name', 'address…
Specifies which fields shouldn't be copied. May also contain arrays
for related entries.
->excluding(['name', 'address_id' => ['city']]);.
|
#
|
public
|
transformData(
array<0, Closure(array<string, mixed>): array<string, mixed>>|array<string, array<mixed>> $transforms,
): $this
Specifies which models data should be transformed while copying.
May also contain arrays for related entries.
Specifies which models data should be transformed while copying.
May also contain arrays for related entries.
->transformData(
[function (array $data) { // for Client entity
$data['name'] => $data['last_name'] . ' ' . $data['first_name'];
unset($data['first_name']);
unset($data['last_name']);
return $data;
}],
'Invoices' => ['Lines' => function (array $data) { // for nested Client->Invoices->Lines hasMany entity
$data['exchanged_amount'] = $data['amount'] * getExRate($data['date'], $data['currency']);
return $data;
}]
);
|
#
|
protected
|
extractKeys(array<int, string>|array<string, array<mixed>> $array): array<string, array<int, string>>
Will extract non-numeric keys from the array.
Will extract non-numeric keys from the array.
|
#
|
public
|
copy(): Model
Copy records.
|
#
|
protected
|
_copy(
Model $source,
Model $destination,
array<int, string>|array<string, array<mixed>> $references,
array<int, string>|array<string, array<mixed>> $exclusions,
array<0, Closure(array<string, mixed>): array<string, mixed>>|array<string, array<mixed>> $transforms,
): Model
Internal method for copying records.
Internal method for copying records.
Returns
|
#
|
| Properties |
protected
|
Model
|
$source
Model from which we want to copy records
Model from which we want to copy records
|
#
|
protected
|
Model
|
$destination
Model into which we want to copy records
Model into which we want to copy records
|
#
|
protected
|
array<int, string>|array<string, array<mixed>>
|
$references = []
|
#
|
protected
|
array<int, string>|array<string, array<mixed>>
|
$exclusions = []
|
#
|
protected
|
array<0, Closure(array<string, mixed>): array<string, mixed>>|array<string, array<mixed>>
|
$transforms = []
|
#
|
public
|
array<string, array<mixed, mixed>>
|
$mapping = []
|
#
|