Many To Many relationships need a junction table containing the primary keys of the two tables needing the many to many relationshp.
In the Record class definition, you need to define a virtual field with the name of the Many To Many 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\ManyToMany::class, followed by the junction table class name, then related table class name. Two additional parameters can be specified, the order by column and sort order (defaults to ASC).
Example:
protected static array $virtualFields = [
'suppliers' => [\PHPFUI\ORM\ManyToMany::class, \Tests\App\Table\ProductSupplier::class, \Tests\App\Table\Supplier::class, 'company', ],
];
CloneableInstantiable
Methods |
public getValue(array $parameters) : PHPFUI
|
public setValue(?mixed $value, array $parameters) : void
|
Properties |