class MorphTo extends BelongsTo (View source)

Methods

void
__construct( Builder $query, Model $parent, string $foreignKey, string $otherKey, string $type, string $relation)

Create a new morph to relationship instance.

void
addConstraints()

Set the base constraints on the relation query.

from BelongsTo
void
addEagerConstraints( array $models)

Set the constraints for an eager load of the relation.

array
initRelation( array $models, string $relation)

Initialize the relation on a set of models.

from BelongsTo
array
match( array $models, Collection $results, string $relation)

Match the eagerly loaded results to their parents.

mixed
getResults()

Get the results of the relationship.

getEager()

Get the results of the relationship.

void
touch()

Touch all of the related models for the relationship.

from Relation
int
rawUpdate( array $attributes = array())

Run a raw update against the base query.

from Relation
getRelationCountQuery( Builder $query, Builder $parent)

Add the constraints for a relationship count query.

from BelongsTo
static  mixed
noConstraints( Closure $callback)

Run a callback with constraints disabled on the relation.

from Relation
getQuery()

Get the underlying query for the relation.

from Relation
getBaseQuery()

Get the base query builder driving the Eloquent builder.

from Relation
getParent()

Get the parent model of the relation.

from Relation
string
getQualifiedParentKeyName()

Get the fully qualified parent key name.

from Relation
getRelated()

Get the related model of the relation.

from Relation
string
createdAt()

Get the name of the "created at" column.

from Relation
string
updatedAt()

Get the name of the "updated at" column.

from Relation
string
relatedUpdatedAt()

Get the name of the related model's "updated at" column.

from Relation
string
wrap( string $value)

Wrap the given value with the parent query's grammar.

from Relation
static  array
morphMap( array $map = null, bool $merge = true)

Set or get the morph map for polymorphic relations.

from Relation
mixed
__call( string $method, array $parameters)

Handle dynamic method calls to the relationship.

from Relation
void
__clone()

Force a clone of the underlying query builder when cloning.

from Relation
getRelationCountQueryForSelfRelation( Builder $query, Builder $parent)

Add the constraints for a relationship count query on the same table.

from BelongsTo
string
getRelationCountHash()

Get a relationship join table hash.

from BelongsTo
associate( Model|int $model)

Associate the model instance to the given parent.

dissociate()

Dissociate previously associated model from the given parent.

mixed
update( array $attributes)

Update the parent model on the relationship.

from BelongsTo
string
getForeignKey()

Get the foreign key of the relationship.

from BelongsTo
string
getQualifiedForeignKey()

Get the fully qualified foreign key of the relationship.

from BelongsTo
string
getOtherKey()

Get the associated key of the relationship.

from BelongsTo
string
getQualifiedOtherKeyName()

Get the fully qualified associated key of the relationship.

from BelongsTo
createModelByType( string $type)

Create a new model instance by type.

string
getMorphType()

Get the foreign key "type" name.

array
getDictionary()

Get the dictionary used by the relationship.

$this
withTrashed()

Fetch soft-deleted model instances with query.

Details

at line line 50
void __construct( Builder $query, Model $parent, string $foreignKey, string $otherKey, string $type, string $relation)

Create a new morph to relationship instance.

Parameters

Builder $query
Model $parent
string $foreignKey
string $otherKey
string $type
string $relation

Return Value

void

in BelongsTo at line line 67
void addConstraints()

Set the base constraints on the relation query.

Return Value

void

at line line 77
void addEagerConstraints( array $models)

Set the constraints for an eager load of the relation.

Parameters

array $models

Return Value

void

in BelongsTo at line line 181
array initRelation( array $models, string $relation)

Initialize the relation on a set of models.

Parameters

array $models
string $relation

Return Value

array

at line line 105
array match( array $models, Collection $results, string $relation)

Match the eagerly loaded results to their parents.

Parameters

array $models
Collection $results
string $relation

Return Value

array

at line line 62
mixed getResults()

Get the results of the relationship.

Return Value

mixed

at line line 146
Collection getEager()

Get the results of the relationship.

Called via eager load method of Eloquent query builder.

Return Value

Collection

in Relation at line line 121
void touch()

Touch all of the related models for the relationship.

Return Value

void

in Relation at line line 134
int rawUpdate( array $attributes = array())

Run a raw update against the base query.

Parameters

array $attributes

Return Value

int

in BelongsTo at line line 86
Builder getRelationCountQuery( Builder $query, Builder $parent)

Add the constraints for a relationship count query.

Parameters

Builder $query
Builder $parent

Return Value

Builder

in Relation at line line 161
static mixed noConstraints( Closure $callback)

Run a callback with constraints disabled on the relation.

Parameters

Closure $callback

Return Value

mixed

in Relation at line line 199
Builder getQuery()

Get the underlying query for the relation.

Return Value

Builder

in Relation at line line 209
Builder getBaseQuery()

Get the base query builder driving the Eloquent builder.

Return Value

Builder

in Relation at line line 219
Model getParent()

Get the parent model of the relation.

Return Value

Model

in Relation at line line 229
string getQualifiedParentKeyName()

Get the fully qualified parent key name.

Return Value

string

in Relation at line line 239
Model getRelated()

Get the related model of the relation.

Return Value

Model

in Relation at line line 249
string createdAt()

Get the name of the "created at" column.

Return Value

string

in Relation at line line 259
string updatedAt()

Get the name of the "updated at" column.

Return Value

string

in Relation at line line 269
string relatedUpdatedAt()

Get the name of the related model's "updated at" column.

Return Value

string

in Relation at line line 280
string wrap( string $value)

Wrap the given value with the parent query's grammar.

Parameters

string $value

Return Value

string

in Relation at line line 292
static array morphMap( array $map = null, bool $merge = true)

Set or get the morph map for polymorphic relations.

Parameters

array $map
bool $merge

Return Value

array

in Relation at line line 329
mixed __call( string $method, array $parameters)

Handle dynamic method calls to the relationship.

Parameters

string $method
array $parameters

Return Value

mixed

in Relation at line line 345
void __clone()

Force a clone of the underlying query builder when cloning.

Return Value

void

in BelongsTo at line line 106
Builder getRelationCountQueryForSelfRelation( Builder $query, Builder $parent)

Add the constraints for a relationship count query on the same table.

Parameters

Builder $query
Builder $parent

Return Value

Builder

in BelongsTo at line line 124
string getRelationCountHash()

Get a relationship join table hash.

Return Value

string

at line line 116
Model associate( Model|int $model)

Associate the model instance to the given parent.

Parameters

Model|int $model

Return Value

Model

at line line 130
Model dissociate()

Dissociate previously associated model from the given parent.

Return Value

Model

in BelongsTo at line line 262
mixed update( array $attributes)

Update the parent model on the relationship.

Parameters

array $attributes

Return Value

mixed

in BelongsTo at line line 274
string getForeignKey()

Get the foreign key of the relationship.

Return Value

string

in BelongsTo at line line 284
string getQualifiedForeignKey()

Get the fully qualified foreign key of the relationship.

Return Value

string

in BelongsTo at line line 294
string getOtherKey()

Get the associated key of the relationship.

Return Value

string

in BelongsTo at line line 304
string getQualifiedOtherKeyName()

Get the fully qualified associated key of the relationship.

Return Value

string

at line line 214
Model createModelByType( string $type)

Create a new model instance by type.

Parameters

string $type

Return Value

Model

at line line 226
string getMorphType()

Get the foreign key "type" name.

Return Value

string

at line line 236
array getDictionary()

Get the dictionary used by the relationship.

Return Value

array

at line line 246
$this withTrashed()

Fetch soft-deleted model instances with query.

Return Value

$this