Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permissions = config('privileges.permissions');
     foreach ($permissions as $name => $description) {
         Permission::create(['name' => $name, 'description' => $description]);
     }
 }
Exemplo n.º 2
0
 /**
  * Delete a permission
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete($id)
 {
     $permission = Permission::find($id);
     if ($permission) {
         $permission->delete();
     }
     return redirect()->route('laradmin.permissions.index')->with('success', 'Permission Was deleted!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role_permissions = config('privileges.role_permission');
     foreach ($role_permissions as $role => $permissions) {
         $role = Role::where('name', $role)->first();
         if ($role) {
             foreach ($permissions as $permission) {
                 $permission_to_attach = Permission::where('name', $permission)->first();
                 if ($permission_to_attach) {
                     $role->permissions()->attach($permission_to_attach->id);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function edit($id)
 {
     $role_to_edit = Role::find($id);
     $all_permissions = Permission::all();
     return view('laradmin::roles.edit', compact('role_to_edit', 'all_permissions'));
 }