trait GuardsAttributes (View source)

Properties

protected array<int,string> $fillable

The attributes that are mass assignable.

protected string[]|bool $guarded

The attributes that aren't mass assignable.

static protected bool $unguarded

Indicates if all mass assignment is enabled.

static protected string[] $guardableColumns

The actual columns that exist on the database and can be guarded.

Methods

string[]
getFillable()

Get the fillable attributes for the model.

$this
fillable(array $fillable)

Set the fillable attributes for the model.

$this
mergeFillable(array $fillable)

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

string[]
getGuarded()

Get the guarded attributes for the model.

$this
guard(array $guarded)

Set the guarded attributes for the model.

$this
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 
unguarded(callable $callback)

No description

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<string,mixed>
fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Details

string[] getFillable()

Get the fillable attributes for the model.

Return Value

string[]

$this fillable(array $fillable)

Set the fillable attributes for the model.

Parameters

array $fillable

Return Value

$this

$this mergeFillable(array $fillable)

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

Parameters

array $fillable

Return Value

$this

string[] getGuarded()

Get the guarded attributes for the model.

Return Value

string[]

$this guard(array $guarded)

Set the guarded attributes for the model.

Parameters

array $guarded

Return Value

$this

$this mergeGuarded(array $guarded)

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

Parameters

array $guarded

Return Value

$this

static void unguard(bool $state = true)

Disable all mass assignable restrictions.

Parameters

bool $state

Return Value

void

static void reguard()

Enable the mass assignment restrictions.

Return Value

void

static bool isUnguarded()

Determine if the current state is "unguarded".

Return Value

bool

static unguarded(callable $callback)

No description

Parameters

callable $callback

bool isFillable(string $key)

Determine if the given attribute may be mass assigned.

Parameters

string $key

Return Value

bool

bool isGuarded(string $key)

Determine if the given key is guarded.

Parameters

string $key

Return Value

bool

protected bool isGuardableColumn(string $key)

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

Parameters

string $key

Return Value

bool

bool totallyGuarded()

Determine if the model is totally guarded.

Return Value

bool

protected array<string,mixed> fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Parameters

array $attributes

Return Value

array<string,mixed>