Property | Type | Description | |
---|---|---|---|
$container | The component container for this relation | ||
$data | The data loaded by this relation | ||
$foreignKey | The foreign table key for this relation | ||
$foreignKeyMap | Maps each local table key to an array of foreign table keys, used in many-to-many relations | ||
$foreignModelClass | The class name of the foreign key's model | ||
$foreignModelComponent | The application name of the foreign model | ||
$foreignModelName | The bade name of the foreign model | ||
$localKey | The local table key for this relation | ||
$parentModel | The data model we are attached to | ||
$pivotForeignKey | For many-to-many relations, the pivot table's column storing the foreign key | ||
$pivotLocalKey | For many-to-many relations, the pivot table's column storing the local key | ||
$pivotTable | For many-to-many relations, the pivot (glue) table |
Method | Description | |
---|---|---|
__construct ( |
Public constructor. Initialises the relation. | |
getCountSubquery ( ) : JDatabaseQuery | Returns the count subquery for DataModel's has() and whereHas() methods. | |
getData ( callable $callback = null, |
Get the relation data. | |
getForeignKeyMap ( ) : array | Returns the foreign key map of a many-to-many relation, used for eager loading many-to-many relations | |
getForeignModel ( array $config = [] ) : |
Gets an object instance of the foreign model | |
getLocalKey ( ) : string | Returns the name of the local key of the relation | |
getNew ( ) : |
Returns a new item of the foreignModel type, pre-initialised to fulfil this relation | |
rebase ( |
Rebase the relation to a different model | |
reset ( ) | Reset the relation data | |
saveAll ( ) | Saves all related items. You can use it to touch items as well: every item being saved causes the modified_by and modified_on fields to be changed automatically, thanks to the DataModel's magic. | |
setDataFromCollection ( |
Populates the internal $this->data collection from the contents of the provided collection. This is used by DataModel to push the eager loaded data into each item's relation. |
Method | Description | |
---|---|---|
filterForeignModel ( |
Applies the relation filters to the foreign model when getData is called |
public __construct ( |
||
$parentModel | The data model we are attached to | |
$foreignModelName | string | The name of the foreign key's model in the format "modelName@com_something" |
$localKey | string | The local table key for this relation |
$foreignKey | string | The foreign key for this relation |
$pivotTable | string | For many-to-many relations, the pivot (glue) table |
$pivotLocalKey | string | For many-to-many relations, the pivot table's column storing the local key |
$pivotForeignKey | string | For many-to-many relations, the pivot table's column storing the foreign key |
abstract protected filterForeignModel ( |
||
$foreignModel | The foreign model you're operating on | |
$dataCollection | If it's an eager loaded relation, the collection of loaded parent records | |
return | boolean | Return false to force an empty data collection |
abstract public getCountSubquery ( ) : JDatabaseQuery | ||
return | JDatabaseQuery |
public getForeignKeyMap ( ) : array | ||
return | array |
public getForeignModel ( array $config = [] ) : |
||
$config | array | Optional configuration information for the Model |
return |
public getLocalKey ( ) : string | ||
return | string |
abstract public getNew ( ) : |
||
return |
public rebase ( |
||
$model |
public saveAll ( ) |
public setDataFromCollection ( |
||
$data | The relation data to push into this relation | |
$keyMap | mixed | Used by many-to-many relations to pass around the local to foreign key map |
return | void |
protected $foreignKeyMap |
protected $foreignModelClass |
protected $foreignModelComponent |
protected $foreignModelName |
protected $pivotForeignKey |
protected $pivotLocalKey |