1

I want to create dynamic permissions for each users through checkbox using Sentry in Laravel 4. I've created a table named permissions that has two columns:

id | name | user_id

Now, I want to use:

Sentry::hasAccess('any_permission_name')

But this 'any_permission_name' should come from permissions table.

I've extend the SentrUserModel in my User model and add this relation to the User model:

    public function permission(){
        return $this->hasMany('Permission');
}

Now, I don't understand how to use Sentry with different permissions table for fetching the permissions. Is there any way to use Sentry for this?

Tahsin Abrar
  • 860
  • 13
  • 22
  • Why do you want to create separate table for this? Sentry provides JSON permissions already. – Jarek Tkaczyk Jan 08 '15 at 12:03
  • I want to create dynamic permissions. Thus, from admin panel, when an admin create a user, he should get all the permissions that is stored in the permissions table and decide which access the user should get. And an admin can create new permissions from panel. – Tahsin Abrar Jan 08 '15 at 16:46
  • Yeah, let me rephrase my comment - why would you store users' permissions in separate table? First of all it won't be `hasMany`, but rather `belongsToMany`, second you should just create table with permissions, and store them in the users table as JSON, the way Sentry does it. Use that table just as a collection of available options. – Jarek Tkaczyk Jan 08 '15 at 19:18

0 Answers0