SupportsDefaultModels
Table of Contents
- $withDefault : Closure|array<string|int, mixed>|bool
- Indicates if a default model instance should be used.
- withDefault() : $this
- Return a new model instance in case the relationship does not exist.
- getDefaultFor() : Model|null
- Get the default value for this relation.
- newRelatedInstanceFor() : Model
- Make a new related instance for the given model.
Properties
$withDefault
Indicates if a default model instance should be used.
protected
Closure|array<string|int, mixed>|bool
$withDefault
Alternatively, may be a Closure or array.
Methods
withDefault()
Return a new model instance in case the relationship does not exist.
public
withDefault([Closure|array<string|int, mixed>|bool $callback = true ]) : $this
Parameters
- $callback : Closure|array<string|int, mixed>|bool = true
Return values
$this —getDefaultFor()
Get the default value for this relation.
protected
getDefaultFor(Model $parent) : Model|null
Parameters
- $parent : Model
Return values
Model|null —newRelatedInstanceFor()
Make a new related instance for the given model.
protected
abstract newRelatedInstanceFor(Model $parent) : Model
Parameters
- $parent : Model