コード例 #1
0
 /**
  * Update the permission.
  *
  * @param Permission $permission Permission
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Permission $permission)
 {
     $this->validate(request(), ['name' => ['required', Rule::unique('permissions')->ignore($permission->id)], 'label' => 'required', 'sort_order' => 'required|integer']);
     if (request()->ajax()) {
         return ajaxSuccess();
     }
     if ($permission->update(['name' => snake_slug(request()->name), 'label' => ucfirst(request()->label), 'sort_order' => request()->sort_order])) {
         flash()->success(trans('admin::messages.success'), trans('admin::permissions.updated', ['name' => request()->name]));
     }
     return redirect()->route('permissions.index');
 }
コード例 #2
0
 /**
  * Get all the permissions.
  *
  * @return array
  */
 protected function getPermissions()
 {
     if (app()->runningInConsole()) {
         return [];
     }
     return Permission::with('roles')->get();
 }
コード例 #3
0
 /**
  * Show the role edit form and assign permissions to a given role.
  *
  * @param Role $role Role
  *
  * @return \Illuminate\View\View
  */
 public function edit(Role $role)
 {
     $role = $role->with('permissions', 'managers', 'users')->first();
     $permissions = Permission::where('is_admin', $role->is_admin)->get();
     return view('admin::roles.edit', compact('role', 'permissions'));
 }