class ModelPropertyHelper

Methods

__construct(TypeStringResolver $stringResolver, MigrationHelper $migrationHelper, SquashedMigrationHelper $squashedMigrationHelper, ModelCastHelper $modelCastHelper, ModelHelper $modelHelper, MigrationCache $migrationCache, DeclarationDependencyTracker $declarationDependencyTracker, ReflectionProvider $reflectionProvider, ConnectionConfigResolver $connectionConfigResolver, DataTypeToPhpTypeConverter $converter, ConfigSourceResolver $configSourceResolver, RuntimeInputs $runtimeInputs)

Create a new model property helper instance.

TrinaryLogic
acceptsPropertyName(Type $modelType, string $propertyName)

Determine if a property name is accepted for a model type, as any name is for an abstract model.

TrinaryLogic
hasDatabaseProperty(ClassReflection $classReflection, string $propertyName)

Determine if the model has a database property, or maybe has one when its schema facts are unknown.

bool
hasTableColumn(ClassReflection $classReflection, string $table, string $column)

Determine if a table on the model's connection has a column, or whether it is unknown.

array
getUnusableDumps(ClassReflection $classReflection)

Get the schema dumps of the model's connection that could not be read.

array|null
getDatabasePropertyNames(ClassReflection $classReflection)

Get the names of the attributes a model fetches from its table, or null when they are not all known.

getDatabaseProperty(ClassReflection $classReflection, string $propertyName)

Get the database property of a model, which also types the directions its accessors and mutators leave to Eloquent.

bool
hasAccessor(ClassReflection $classReflection, string $propertyName)

Determine if an accessor or mutator handles the property, as a get{Name}Attribute() or set{Name}Attribute() method or an Attribute method.

getAccessor(ClassReflection $classReflection, string $propertyName)

Get the property an accessor or mutator provides.

Type|null
getGetMutatorType(ClassReflection $classReflection, string $propertyName)

Get the type a get{Name}Attribute() accessor returns, or null when there is none.

Type|null
getAttributeGetMutatorType(ClassReflection $classReflection, string $propertyName)

Get the type an Attribute accessor's get callback returns, or null when it has none.

void
trackSchemaDependency(ClassReflection $classReflection)

Track the schema inputs as dependencies of the class.

Details

at line 73
__construct(TypeStringResolver $stringResolver, MigrationHelper $migrationHelper, SquashedMigrationHelper $squashedMigrationHelper, ModelCastHelper $modelCastHelper, ModelHelper $modelHelper, MigrationCache $migrationCache, DeclarationDependencyTracker $declarationDependencyTracker, ReflectionProvider $reflectionProvider, ConnectionConfigResolver $connectionConfigResolver, DataTypeToPhpTypeConverter $converter, ConfigSourceResolver $configSourceResolver, RuntimeInputs $runtimeInputs)

Create a new model property helper instance.

Parameters

TypeStringResolver $stringResolver
MigrationHelper $migrationHelper
SquashedMigrationHelper $squashedMigrationHelper
ModelCastHelper $modelCastHelper
ModelHelper $modelHelper
MigrationCache $migrationCache
DeclarationDependencyTracker $declarationDependencyTracker
ReflectionProvider $reflectionProvider
ConnectionConfigResolver $connectionConfigResolver
DataTypeToPhpTypeConverter $converter
ConfigSourceResolver $configSourceResolver
RuntimeInputs $runtimeInputs

at line 95
TrinaryLogic acceptsPropertyName(Type $modelType, string $propertyName)

Determine if a property name is accepted for a model type, as any name is for an abstract model.

An abstract model, including Model itself and template bounds, stands for its subclasses, so any name may be one of their attributes. ModelPropertyExtension does not claim these names.

Parameters

Type $modelType
string $propertyName

Return Value

TrinaryLogic

at line 113
TrinaryLogic hasDatabaseProperty(ClassReflection $classReflection, string $propertyName)

Determine if the model has a database property, or maybe has one when its schema facts are unknown.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

TrinaryLogic

at line 152
bool hasTableColumn(ClassReflection $classReflection, string $table, string $column)

Determine if a table on the model's connection has a column, or whether it is unknown.

Unlike upstream, the table is looked up on the model's connection rather than by name alone, and a table missing from the facts is not claimed, since a query can name a table by an alias.

Parameters

ClassReflection $classReflection
string $table
string $column

Return Value

bool

at line 170
array getUnusableDumps(ClassReflection $classReflection)

Get the schema dumps of the model's connection that could not be read.

Parameters

ClassReflection $classReflection

Return Value

array

at line 190
array|null getDatabasePropertyNames(ClassReflection $classReflection)

Get the names of the attributes a model fetches from its table, or null when they are not all known.

Parameters

ClassReflection $classReflection

Return Value

array|null

at line 217
ModelProperty getDatabaseProperty(ClassReflection $classReflection, string $propertyName)

Get the database property of a model, which also types the directions its accessors and mutators leave to Eloquent.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

ModelProperty

at line 473
bool hasAccessor(ClassReflection $classReflection, string $propertyName)

Determine if an accessor or mutator handles the property, as a get{Name}Attribute() or set{Name}Attribute() method or an Attribute method.

Unlike upstream, public Attribute methods and those without generics count, as Eloquent uses them too.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

bool

at line 488
ModelProperty getAccessor(ClassReflection $classReflection, string $propertyName)

Get the property an accessor or mutator provides.

Each direction follows Eloquent's precedence: the get{Name}Attribute() or set{Name}Attribute() method, then the Attribute callback, then the database property with its casts. Unlike upstream, a direction without a callback is not refused, since Eloquent then reads or writes the attribute itself.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

ModelProperty

at line 513
Type|null getGetMutatorType(ClassReflection $classReflection, string $propertyName)

Get the type a get{Name}Attribute() accessor returns, or null when there is none.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

Type|null

at line 525
Type|null getAttributeGetMutatorType(ClassReflection $classReflection, string $propertyName)

Get the type an Attribute accessor's get callback returns, or null when it has none.

Parameters

ClassReflection $classReflection
string $propertyName

Return Value

Type|null

at line 628
void trackSchemaDependency(ClassReflection $classReflection)

Track the schema inputs as dependencies of the class.

What the class declares depends on the database schema, which comes from the migrations, the schema dumps, the config they read and the PHP files naming their tables and connections. Each file depending on the class is analyzed again when one of them is created, changed or deleted. The files a table's columns were read from are tracked on the models reading it.

Parameters

ClassReflection $classReflection

Return Value

void