trait InteractsWithModels (View source)

Methods

TModel|null
model(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the model identified by the given input.

TModel
modelOrFail(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the model identified by the given input or throw an exception.

TModel>
models(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the models identified by the given input.

TModel>
newModelQuery(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Create a model query for the given input key.

Model>
guessModelClass(string $key)

Guess the model class for the given input key.

Details

TModel|null model(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the model identified by the given input.

Parameters

string $key
TModel>|Closure|null $modelClass
Closure|null $callback

Return Value

TModel|null

TModel modelOrFail(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the model identified by the given input or throw an exception.

Parameters

string $key
TModel>|Closure|null $modelClass
Closure|null $callback

Return Value

TModel

Exceptions

TModel>

TModel> models(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Retrieve the models identified by the given input.

Parameters

string $key
TModel>|Closure|null $modelClass
Closure|null $callback

Return Value

TModel>

protected TModel> newModelQuery(string $key, TModel>|Closure|null $modelClass = null, Closure|null $callback = null)

Create a model query for the given input key.

Parameters

string $key
TModel>|Closure|null $modelClass
Closure|null $callback

Return Value

TModel>

protected Model> guessModelClass(string $key)

Guess the model class for the given input key.

Parameters

string $key

Return Value

Model>