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. |
Methods
Initialize the GuardsAttributes trait.
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 39
void
initializeGuardsAttributes()
Initialize the GuardsAttributes trait.
at line 58
array
getFillable()
Get the fillable attributes for the model.
at line 68
GuardsAttributes
fillable(array $fillable)
Set the fillable attributes for the model.
at line 80
GuardsAttributes
mergeFillable(array $fillable)
Merge new fillable attributes with existing fillable attributes on the model.
at line 96
array
getGuarded()
Get the guarded attributes for the model.
at line 108
GuardsAttributes
guard(array $guarded)
Set the guarded attributes for the model.
at line 120
GuardsAttributes
mergeGuarded(array $guarded)
Merge new guarded attributes with existing guarded attributes on the model.
at line 132
static void
unguard(bool $state = true)
Disable all mass assignable restrictions.
Uses Context for coroutine-safe state management.
at line 140
static void
reguard()
Enable the mass assignment restrictions.
at line 148
static bool
isUnguarded()
Determine if the current state is "unguarded".
at line 164
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 183
bool
isFillable(string $key)
Determine if the given attribute may be mass assigned.
at line 211
bool
isGuarded(string $key)
Determine if the given key is guarded.
at line 225
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
at line 249
bool
totallyGuarded()
Determine if the model is totally guarded.
at line 260
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.