PHP 클래스 FOF30\Model\DataModel\Relation\BelongsToMany

For example, parentModel is Users and foreignModel is Groups. Each user can be assigned to many groups. Each group can be assigned to many users.
상속: extends FOF30\Model\DataModel\Relation
파일 보기 프로젝트 열기: akeeba/fof 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( DataModel $parentModel, string $foreignModelName, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null ) Public constructor. Initialises the relation.
getCountSubquery ( string $tableAlias = null ) : JDatabaseQuery Returns the count subquery for DataModel's has() and whereHas() methods.
getNew ( ) This is not supported by the belongsTo relation
saveAll ( ) Saves all related items. For many-to-many relations there are two things we have to do: 1. Save all related items; and 2. Overwrite the pivot table data with the new associations
saveRelations ( ) Overwrite the pivot table data with the new associations
setDataFromCollection ( Collection &$data, mixed $keyMap = null ) : void 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.

보호된 메소드들

메소드 설명
filterForeignModel ( DataModel $foreignModel, Collection $dataCollection = null ) : boolean Applies the relation filters to the foreign model when getData is called

메소드 상세

__construct() 공개 메소드

Public constructor. Initialises the relation.
public __construct ( DataModel $parentModel, string $foreignModelName, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null )
$parentModel FOF30\Model\DataModel 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, default: parentModel's ID field name
$foreignKey string The foreign key for this relation, default: parentModel's ID field name
$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

filterForeignModel() 보호된 메소드

Applies the relation filters to the foreign model when getData is called
protected filterForeignModel ( DataModel $foreignModel, Collection $dataCollection = null ) : boolean
$foreignModel FOF30\Model\DataModel The foreign model you're operating on
$dataCollection FOF30\Model\DataModel\Collection If it's an eager loaded relation, the collection of loaded parent records
리턴 boolean Return false to force an empty data collection

getCountSubquery() 공개 메소드

Returns the count subquery for DataModel's has() and whereHas() methods.
public getCountSubquery ( string $tableAlias = null ) : JDatabaseQuery
$tableAlias string The alias of the local table in the query. Leave blank to use the table's name.
리턴 JDatabaseQuery

getNew() 공개 메소드

This is not supported by the belongsTo relation
public getNew ( )

saveAll() 공개 메소드

Saves all related items. For many-to-many relations there are two things we have to do: 1. Save all related items; and 2. Overwrite the pivot table data with the new associations
public saveAll ( )

saveRelations() 공개 메소드

Overwrite the pivot table data with the new associations
public saveRelations ( )

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.
public setDataFromCollection ( Collection &$data, mixed $keyMap = null ) : void
$data FOF30\Model\DataModel\Collection The relation data to push into this relation
$keyMap mixed Passes around the local to foreign key map
리턴 void