GuardsAttributes
trait GuardsAttributes
Properties
| protected array<int, string> | $fillable | The attributes that are mass assignable. |
|
| protected string[] | $guarded | The attributes that aren't mass assignable. |
|
| static protected array<class-string, list<string>> | $guardableColumns | The actual columns that exist on the database and can be guarded. |
|
| static protected array<class-string, array{guarded: null|array<int, string>, propertyDefault: array<int, string>}> | $guardConfigurations | The resolved guard configuration for each model class. |
Methods
Initialize the GuardsAttributes trait.
Resolve the nearest guard configuration for the model class.
Resolve guard configuration declared by traits at one class level.
Get the fillable attributes for the model.
Set the fillable attributes for the model.
Merge new fillable attributes with existing fillable attributes on the model.
Get the guarded attributes for the model.
Set the guarded attributes for the model.
Merge new guarded attributes with existing guarded attributes on the model.
Disable all mass assignable restrictions.
Enable the mass assignment restrictions.
Determine if the current state is "unguarded".
Run the given callable while being unguarded.
Determine if the given attribute may be mass assigned.
Determine if the given key is guarded.
Determine if the given column is a valid, guardable column.
Determine if the model is totally guarded.
Get the fillable attributes of a given array.
Details
at line 48
void
initializeGuardsAttributes()
Initialize the GuardsAttributes trait.
at line 72
static protected array
guardConfiguration()
Resolve the nearest guard configuration for the model class.
at line 126
static protected array|null
guardConfigurationFromTraits(array $traits)
Resolve guard configuration declared by traits at one class level.
at line 149
array
getFillable()
Get the fillable attributes for the model.
at line 159
GuardsAttributes
fillable(array $fillable)
Set the fillable attributes for the model.
at line 171
GuardsAttributes
mergeFillable(array $fillable)
Merge new fillable attributes with existing fillable attributes on the model.
at line 187
array
getGuarded()
Get the guarded attributes for the model.
at line 199
GuardsAttributes
guard(array $guarded)
Set the guarded attributes for the model.
at line 211
GuardsAttributes
mergeGuarded(array $guarded)
Merge new guarded attributes with existing guarded attributes on the model.
at line 223
static void
unguard(bool $state = true)
Disable all mass assignable restrictions.
Uses Context for coroutine-safe state management.
at line 231
static void
reguard()
Enable the mass assignment restrictions.
at line 239
static bool
isUnguarded()
Determine if the current state is "unguarded".
at line 255
static mixed
unguarded(callable $callback)
Run the given callable while being unguarded.
Uses Context for coroutine-safe state management, ensuring concurrent requests don't interfere with each other's guarding state.
at line 274
bool
isFillable(string $key)
Determine if the given attribute may be mass assigned.
at line 302
bool
isGuarded(string $key)
Determine if the given key is guarded.
at line 316
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
at line 340
bool
totallyGuarded()
Determine if the model is totally guarded.
at line 351
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.