Bas
Bas

Reputation: 2400

Laravel disable column in eleoquent model

We have an application with a table, what i want is to disable/read-only one column in my Model, in my example fakecolumn.

So not massasign with $fillable.

I don't want any actions tobe done on that specific column.

Table:

id
name
email
fakecolumn

How can i achieve that and is it also possible?

Upvotes: 1

Views: 383

Answers (1)

Thomas
Thomas

Reputation: 8859

You can use an empty Mutator:

public function setFakecolumnAttribute() {}

If you do want to set/update it at some point, you can directly modify the value in the $attributes property of the model:

public function init()
{
    $this->attributes['facecolumn'] = true;
}

Upvotes: 2

Related Questions