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

void
initializeGuardsAttributes()

Initialize the GuardsAttributes trait.

array
getFillable()

Get the fillable attributes for the model.

fillable(array $fillable)

Set the fillable attributes for the model.

mergeFillable(array $fillable)

Merge new fillable attributes with existing fillable attributes on the model.

array
getGuarded()

Get the guarded attributes for the model.

guard(array $guarded)

Set the guarded attributes for the model.

mergeGuarded(array $guarded)

Merge new guarded attributes with existing guarded attributes on the model.

static void
unguard(bool $state = true)

Disable all mass assignable restrictions.

static void
reguard()

Enable the mass assignment restrictions.

static bool
isUnguarded()

Determine if the current state is "unguarded".

static mixed
unguarded(callable $callback)

Run the given callable while being unguarded.

bool
isFillable(string $key)

Determine if the given attribute may be mass assigned.

bool
isGuarded(string $key)

Determine if the given key is guarded.

bool
isGuardableColumn(string $key)

Determine if the given column is a valid, guardable column.

bool
totallyGuarded()

Determine if the model is totally guarded.

array
fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Details

at line 39
void initializeGuardsAttributes()

Initialize the GuardsAttributes trait.

Return Value

void

at line 58
array getFillable()

Get the fillable attributes for the model.

Return Value

array

at line 68
GuardsAttributes fillable(array $fillable)

Set the fillable attributes for the model.

Parameters

array $fillable

Return Value

GuardsAttributes

at line 80
GuardsAttributes mergeFillable(array $fillable)

Merge new fillable attributes with existing fillable attributes on the model.

Parameters

array $fillable

Return Value

GuardsAttributes

at line 96
array getGuarded()

Get the guarded attributes for the model.

Return Value

array

at line 108
GuardsAttributes guard(array $guarded)

Set the guarded attributes for the model.

Parameters

array $guarded

Return Value

GuardsAttributes

at line 120
GuardsAttributes mergeGuarded(array $guarded)

Merge new guarded attributes with existing guarded attributes on the model.

Parameters

array $guarded

Return Value

GuardsAttributes

at line 132
static void unguard(bool $state = true)

Disable all mass assignable restrictions.

Uses Context for coroutine-safe state management.

Parameters

bool $state

Return Value

void

at line 140
static void reguard()

Enable the mass assignment restrictions.

Return Value

void

at line 148
static bool isUnguarded()

Determine if the current state is "unguarded".

Return Value

bool

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.

Parameters

callable $callback

Return Value

mixed

at line 183
bool isFillable(string $key)

Determine if the given attribute may be mass assigned.

Parameters

string $key

Return Value

bool

at line 211
bool isGuarded(string $key)

Determine if the given key is guarded.

Parameters

string $key

Return Value

bool

at line 225
protected bool isGuardableColumn(string $key)

Determine if the given column is a valid, guardable column.

Parameters

string $key

Return Value

bool

at line 249
bool totallyGuarded()

Determine if the model is totally guarded.

Return Value

bool

at line 260
protected array fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Parameters

array $attributes

Return Value

array