trait Illuminate / Database / Eloquent / Relations / Concerns / SupportsDefaultModels
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

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