Back

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();

Thoughts?

groovenectar replied 3 years ago

This ended up working well:

http://laravel.io/bin/MOBxQ#

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 9 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