class ModelInspector

Properties

protected list<string> $relationMethods

The methods that can be called in a model to indicate a relation.

Methods

__construct(Application $app)

Create a new model inspector instance.

inspect(string $model, string|null $connection = null)

Extract model details for the given model.

getAttributes(Model $model)

Get the column attributes for the given model.

getVirtualAttributes(Model $model, array $columns)

Get the virtual (non-column) attributes for the given model.

getRelations(Model $model)

Get the relations from the given model.

string|null
getPolicy(Model $model)

Get the first policy associated with this model.

getEvents(Model $model)

Get the events that the model dispatches.

getObservers(Model $model)

Get the observers watching this model.

string
getCollectedBy(Model $model)

Get the collection class being used by the model.

string
getBuilder(Model $model)

Get the builder class being used by the model.

string|null
getResource(Model $model)

Get the class used for JSON response transforming.

string
qualifyModel(string $model)

Qualify the given model class base name.

string|null
getCastType(string $column, Model $model)

Get the cast type for the given column.

getCastsWithDates(Model $model)

Get the model casts, including any date casts.

bool
attributeIsHidden(string $attribute, Model $model)

Determine if the given attribute is hidden.

mixed
getColumnDefault(array $column, Model $model)

Get the default value for the given column.

bool
columnIsUnique(string $column, array $indexes)

Determine if the given attribute is unique.

Details

at line 43
__construct(Application $app)

Create a new model inspector instance.

Parameters

Application $app

at line 55
ModelInfo inspect(string $model, string|null $connection = null)

Extract model details for the given model.

Parameters

string $model
string|null $connection

Return Value

ModelInfo

Exceptions

BindingResolutionException

at line 88
protected Collection getAttributes(Model $model)

Get the column attributes for the given model.

Parameters

Model $model

Return Value

Collection

at line 118
protected Collection getVirtualAttributes(Model $model, array $columns)

Get the virtual (non-column) attributes for the given model.

Parameters

Model $model
array $columns

Return Value

Collection

at line 158
protected Collection getRelations(Model $model)

Get the relations from the given model.

Parameters

Model $model

Return Value

Collection

at line 207
protected string|null getPolicy(Model $model)

Get the first policy associated with this model.

Parameters

Model $model

Return Value

string|null

at line 219
protected Collection getEvents(Model $model)

Get the events that the model dispatches.

Parameters

Model $model

Return Value

Collection

at line 236
protected Collection getObservers(Model $model)

Get the observers watching this model.

Parameters

Model $model

Return Value

Collection

Exceptions

BindingResolutionException

at line 269
protected string getCollectedBy(Model $model)

Get the collection class being used by the model.

Parameters

Model $model

Return Value

string

at line 279
protected string getBuilder(Model $model)

Get the builder class being used by the model.

Parameters

Model $model

Return Value

string

at line 289
protected string|null getResource(Model $model)

Get the class used for JSON response transforming.

Parameters

Model $model

Return Value

string|null

at line 301
protected string qualifyModel(string $model)

Qualify the given model class base name.

Parameters

string $model

Return Value

string

See also

GeneratorCommand

at line 325
protected string|null getCastType(string $column, Model $model)

Get the cast type for the given column.

Parameters

string $column
Model $model

Return Value

string|null

at line 343
protected Collection getCastsWithDates(Model $model)

Get the model casts, including any date casts.

Parameters

Model $model

Return Value

Collection

at line 356
protected bool attributeIsHidden(string $attribute, Model $model)

Determine if the given attribute is hidden.

Parameters

string $attribute
Model $model

Return Value

bool

at line 372
protected mixed getColumnDefault(array $column, Model $model)

Get the default value for the given column.

Parameters

array $column
Model $model

Return Value

mixed

at line 382
protected bool columnIsUnique(string $column, array $indexes)

Determine if the given attribute is unique.

Parameters

string $column
array $indexes

Return Value

bool