Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permission = Permission::create(['name' => 'manage-permissions', 'gb' => ['title' => 'Manage permissions', 'description' => 'Can manage permissions']]);
     $permission = Permission::create(['name' => 'manage-roles', 'gb' => ['title' => 'Manage roles', 'description' => 'Can manage roles']]);
     $permission = Permission::create(['name' => 'manage-admin-users', 'gb' => ['title' => 'Manage admin users', 'description' => 'Can manage admin users']]);
     $permission = Permission::create(['name' => 'manage-pages', 'gb' => ['title' => 'Manage pages', 'description' => 'Can manage pages']]);
     $permission = Permission::create(['name' => 'manage-galleries', 'gb' => ['title' => 'Manage galeries', 'description' => 'Can manage galleries']]);
     /*$permission = Permission::create([
                 'name' => 'manage-categories',
                 'gb' => [
                     'title' => 'Manage categories',
                     'description' => 'Can manage categories'
                 ]
             ]);
     
             $permission = Permission::create([
                 'name' => 'manage-tags',
                 'gb' => [
                     'title' => 'Manage tags',
                     'description' => 'Can manage tags'
                 ]
             ]);
     
             $permission = Permission::create([
                 'name' => 'manage-posts',
                 'gb' => [
                     'title' => 'Manage posts',
                     'description' => 'Can manage posts'
                 ]
             ]);*/
 }
Beispiel #2
0
 public function addPermissionByName($permissionName)
 {
     $permission = Permission::where('name', $permissionName)->first();
     if ($permission) {
         $this->addPermission($permission);
     }
 }
Beispiel #3
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string  $role
  * @return mixed
  */
 public function handle($request, Closure $next, $permissionName)
 {
     $permission = Permission::where('name', $permissionName)->first();
     if (!Auth::admin()->user()->hasPermission($permission)) {
         abort(403);
     }
     return $next($request);
 }
Beispiel #4
0
 public function edit(Request $request, $roleId)
 {
     $role = Role::find($roleId);
     if (!$role) {
         abort(404);
     }
     $permissions = Permission::all();
     return view('lara-mvcms::administration.roles.edit')->with('role', $role)->with('permissions', $permissions);
 }
 public function destroy(Request $request, $permissionId)
 {
     $permission = Permission::find($permissionId);
     if (!$permission) {
         abort(404);
     }
     $permission->delete();
     $request->session()->flash('success', trans('lara-mvcms::permissions.delete-success'));
     return redirect()->route('lara-mvcms.administration.permissions.index');
 }