trait SupportsDefaultModels

Properties

protected Closure|array|bool $withDefault

Indicates if a default model instance should be used.

Methods

newRelatedInstanceFor(Model $parent)

Make a new related instance for the given model.

withDefault(Closure|array|bool $callback = true)

Return a new model instance in case the relationship does not exist.

Model|null
getDefaultFor(Model $parent)

Get the default value for this relation.

Details

at line 22
abstract protected Model newRelatedInstanceFor(Model $parent)

Make a new related instance for the given model.

Parameters

Model $parent

Return Value

Model

at line 29
SupportsDefaultModels withDefault(Closure|array|bool $callback = true)

Return a new model instance in case the relationship does not exist.

Parameters

Closure|array|bool $callback

Return Value

SupportsDefaultModels

at line 39
protected Model|null getDefaultFor(Model $parent)

Get the default value for this relation.

Parameters

Model $parent

Return Value

Model|null