Laravel 4 Role Based Mass Assignment
Asked Answered
R

1

1

Ive justed started using laravel and I am curious to know if laravel-4 offers role based mass assignment straight out of the box ?

I wish to allow some users access to those fields(via mass assignment), when editing/updating Information.

I believe Rails Active record has this feature.

class User < ActiveRecord::Base
  attr_accessible :first, :last, :email             # :default role
  attr_accessible :can_fire_missiles, :as => :admin # :admin role
end
Reiff answered 30/8, 2013 at 20:56 Comment(0)
O
1

Nope! Laravel doesn't have the concept of "roles" out of the box. This may make for a good feature request.

You can, right now, define which fields are "hidden", which are "visible", and to your point, which are "fillable" (mass assignable) and which are not mass-assignable.

Ornery answered 31/8, 2013 at 15:45 Comment(1)
This would a great feature. The admin section of a site would need to keep using Eloquent::unguard() in order to get around this, which is not a very good solution, especially when multiple permission levels are needed (like for managers instead of admins, for example). Would be nice to get this functionality in natively!Heartwarming

© 2022 - 2024 — McMap. All rights reserved.