trait Illuminate / Database / Eloquent / Relations / Concerns / SupportsDefaultModels
You are viewing an older version of the documentation. For the latest, please visit master documentation.

SupportsDefaultModels

Properties

protected

$withDefault Closure |array|bool

Indicates if a default model instance should be used.

Alternatively, may be a Closure or array.

Default: null

Methods

protected abstract

newRelatedInstanceFor ( Model $parent ) : Model

Make a new related instance for the given model.

Parameters

public

withDefault ( $callback ) : $this

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

Parameters

protected

getDefaultFor ( Model $parent ) : Model |null

Get the default value for this relation.

Parameters