W3cubDocs

/Laravel 8

ComparesRelatedModels

trait ComparesRelatedModels (View source)

Methods

bool is(Model|null $model)

Determine if the model is the related instance of the relationship.

bool isNot(Model|null $model)

Determine if the model is not the related instance of the relationship.

mixed getParentKey()

Get the value of the parent model's key.

mixed getRelatedKeyFrom(Model $model)

Get the value of the model's related key.

bool compareKeys(mixed $parentKey, mixed $relatedKey)

Compare the parent key with the related key.

Details

bool is(Model|null $model)

Determine if the model is the related instance of the relationship.

Parameters

Model|null $model

Return Value

bool

bool isNot(Model|null $model)

Determine if the model is not the related instance of the relationship.

Parameters

Model|null $model

Return Value

bool

abstract mixed getParentKey()

Get the value of the parent model's key.

Return Value

mixed

abstract protected mixed getRelatedKeyFrom(Model $model)

Get the value of the model's related key.

Parameters

Model $model

Return Value

mixed

protected bool compareKeys(mixed $parentKey, mixed $relatedKey)

Compare the parent key with the related key.

Parameters

mixed $parentKey
mixed $relatedKey

Return Value

bool

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Database/Eloquent/Relations/Concerns/ComparesRelatedModels.html