A MorphMany class to mimic Eloquent MorphMany.
Requirements:
The morphing records needs two fields: an integer related key and a string field type long enough to hold the table name of the relationship. They should both be prefixed with the morph field prefix passed into the class. The related key field should follow the same id naming conventions as the rest of the database.
In the Record class definition, you need to define a virtual field with the name of the MorphMany relationship. The key of the virtual field is the member name and the value is an array.
The values in the array should be \PHPFUI\ORM\MorphMany::class, followed by the morphing table class name, then morph field prefix. Sort field and sort order are optional fields.
Example:
protected static array $virtualFields = [
'images' => [\PHPFUI\ORM\MorphToMany::class, \Tests\App\Table\Image::class, 'imageable', ],
];
Methods |
public getValue(array $parameters) : PHPFUI
|
public setValue(?mixed $value, array $parameters) : void
|
Properties |