Is it possible to have Eloquent model $fillable attributes conditionally?

For example, you might have a "My Account" section on the frontend for users, and a User Edit section for administrators that use the same model. Those would likely have different fillable values. Any good solutions for that?

Also, in my opinion it would be nice to be able to access the getFillable() method statically, i.e. User::getFillable(), rather than:

$user = new User; $user->getFillable();


groovenectar replied 2 years ago

This ended up working well:

Some people argue that it goes against core MVC, but in my opinion doing it this way is better than over complicating it to fit "strict MVC." It fits contextually.

ToothlessRebel replied 6 months ago

I would agree with having this statically available would be grand.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us