PHP Class Znck\Eloquent\Relations\BelongsToThrough

Author: Rahul Kadyan ([email protected])
Inheritance: extends Illuminate\Database\Eloquent\Relations\Relation
Show file Open project: znck/belongs-to-through

Protected Properties

Property Type Description
$localKey string The local key on the relationship.
$models Illuminate\Database\Eloquent\Model[] List of intermediate model instances.

Public Methods

Method Description
__construct ( Builder $query, Model $parent, array $models, string | null $localKey = null, string $prefix = '', array $foreignKeyLookup = [] ) Create a new instance of relation.
addConstraints ( ) Set the base constraints on the relation query.
addEagerConstraints ( array $models ) Set the constraints for an eager load of the relation.
getQuery ( ) : Builder | Builder Get the underlying query for the relation.
getRelationQuery ( Builder $query, Builder $parent, array | mixed $columns = ['*'] ) : Builder Add the constraints for a relationship query.
getResults ( ) : Model Get the results of the relationship.
hasSoftDeletes ( Model $model ) : boolean Determine whether the model uses Soft Deletes.
initRelation ( array $models, string $relation ) : array Initialize the relation on a set of models.
match ( array $models, Illuminate\Database\Eloquent\Collection $results, string $relation ) : array Match the eagerly loaded results to their parents.

Protected Methods

Method Description
buildDictionary ( Illuminate\Database\Eloquent\Collection $results ) : array Build model dictionary keyed by the relation's foreign key.
getForeignKey ( Model $model ) : string Get foreign key column name for the model.
setJoins ( ) Set the required joins on the relation query.
setRelationQueryConstraints ( Builder $query )
setSoftDeletes ( ) Set the soft deleting constraints on the relation query.

Method Details

__construct() public method

Create a new instance of relation.
public __construct ( Builder $query, Model $parent, array $models, string | null $localKey = null, string $prefix = '', array $foreignKeyLookup = [] )
$query Illuminate\Database\Eloquent\Builder
$parent Illuminate\Database\Eloquent\Model
$models array
$localKey string | null
$prefix string
$foreignKeyLookup array

addConstraints() public method

Set the base constraints on the relation query.
public addConstraints ( )

addEagerConstraints() public method

Set the constraints for an eager load of the relation.
public addEagerConstraints ( array $models )
$models array

buildDictionary() protected method

Build model dictionary keyed by the relation's foreign key.
protected buildDictionary ( Illuminate\Database\Eloquent\Collection $results ) : array
$results Illuminate\Database\Eloquent\Collection
return array

getForeignKey() protected method

Get foreign key column name for the model.
protected getForeignKey ( Model $model ) : string
$model Illuminate\Database\Eloquent\Model
return string

getQuery() public method

Get the underlying query for the relation.
public getQuery ( ) : Builder | Builder
return Illuminate\Database\Eloquent\Builder | Illuminate\Database\Query\Builder

getRelationQuery() public method

Add the constraints for a relationship query.
public getRelationQuery ( Builder $query, Builder $parent, array | mixed $columns = ['*'] ) : Builder
$query Illuminate\Database\Eloquent\Builder
$parent Illuminate\Database\Eloquent\Builder
$columns array | mixed
return Illuminate\Database\Eloquent\Builder

getResults() public method

Get the results of the relationship.
public getResults ( ) : Model
return Illuminate\Database\Eloquent\Model

hasSoftDeletes() public method

Determine whether the model uses Soft Deletes.
public hasSoftDeletes ( Model $model ) : boolean
$model Illuminate\Database\Eloquent\Model
return boolean

initRelation() public method

Initialize the relation on a set of models.
public initRelation ( array $models, string $relation ) : array
$models array
$relation string
return array

match() public method

Match the eagerly loaded results to their parents.
public match ( array $models, Illuminate\Database\Eloquent\Collection $results, string $relation ) : array
$models array
$results Illuminate\Database\Eloquent\Collection
$relation string
return array

setJoins() protected method

Set the required joins on the relation query.
protected setJoins ( )

setRelationQueryConstraints() protected method

protected setRelationQueryConstraints ( Builder $query )
$query Illuminate\Database\Eloquent\Builder

setSoftDeletes() protected method

Set the soft deleting constraints on the relation query.
protected setSoftDeletes ( )

Property Details

$localKey protected property

The local key on the relationship.
protected string $localKey
return string

$models protected property

List of intermediate model instances.
protected Model[],Illuminate\Database\Eloquent $models
return Illuminate\Database\Eloquent\Model[]