ModelPropertyHelper
class ModelPropertyHelper
Methods
Create a new model property helper instance.
Determine if a property name is accepted for a model type, as any name is for an abstract model.
Determine if the model has a database property, or maybe has one when its schema facts are unknown.
Determine if a table on the model's connection has a column, or whether it is unknown.
Get the schema dumps of the model's connection that could not be read.
Get the names of the attributes a model fetches from its table, or null when they are not all known.
Get the database property of a model, which also types the directions its accessors and mutators leave to Eloquent.
Determine if an accessor or mutator handles the property, as a get{Name}Attribute() or set{Name}Attribute() method or an Attribute method.
Get the property an accessor or mutator provides.
Get the type a get{Name}Attribute() accessor returns, or null when there is none.
Get the type an Attribute accessor's get callback returns, or null when it has none.
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.
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.
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.
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.
at line 170
array
getUnusableDumps(ClassReflection $classReflection)
Get the schema dumps of the model's connection that could not be read.
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.
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.
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.
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.
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.
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.
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.