->loadStateFromRelationshipsUsing(function (User $record) {
// Retrieve the organisation IDs managed by the user
$organisationIds = $record->morphedOrganisations()->pluck(
(new Organisation())->getQualifiedKeyName()
)->toArray();
// Retrieve the product IDs managed by the user
$productIds = $record->morphedProducts()->pluck(
(new Product())->getQualifiedKeyName()
)->toArray();
dd(array_merge($organisationIds, $productIds));
// Combine both arrays of IDs
return array_merge($organisationIds, $productIds);
})
->loadStateFromRelationshipsUsing(function (User $record) {
// Retrieve the organisation IDs managed by the user
$organisationIds = $record->morphedOrganisations()->pluck(
(new Organisation())->getQualifiedKeyName()
)->toArray();
// Retrieve the product IDs managed by the user
$productIds = $record->morphedProducts()->pluck(
(new Product())->getQualifiedKeyName()
)->toArray();
dd(array_merge($organisationIds, $productIds));
// Combine both arrays of IDs
return array_merge($organisationIds, $productIds);
})