예제 #1
0
 public function edit($id)
 {
     $permission = Permission::with('roles')->find($id);
     $title = 'Edit Permission';
     $roles = Role::get()->sortBy('name');
     return view('profio/auth::permission.create', compact('permission', 'title', 'roles'));
 }
예제 #2
0
 public function mapping($id, Request $request)
 {
     $workflow = Workflow::find($id);
     if ($request->isMethod('get')) {
         $workflow->load('menus');
         $title = 'Pemetaan Proses Aliran Kerja';
         $roles = Role::get()->pluck('display_name', 'id');
         $menus = Menu::get()->pluck('name', 'id');
         return view('profio/auth::workflow.mapping', compact('workflow', 'title', 'roles', 'menus'));
     } else {
         $workflow->menus()->detach();
         $workflow->permissions()->detach();
         $role_ids = $request->input('role_ids');
         $menu_ids = $request->input('menu_ids');
         DB::transaction(function () use($role_ids, $workflow, $menu_ids) {
             foreach ($role_ids as $key => $role_id) {
                 $workflow->menus()->attach($menu_ids[$key], ['role_id' => $role_id]);
                 $menu = Menu::find($menu_ids[$key]);
                 foreach ($menu->permissions as $permission) {
                     $workflow->permissions()->attach($permission->id, ['role_id' => $role_id]);
                 }
             }
             flash()->success('Pemetaan proses aliran kerja berhasil disimpan.');
         });
         return redirect()->back();
     }
 }
예제 #3
0
 public function edit($id)
 {
     $menu = Menu::with('permissions')->find($id);
     $menu->role_id = $menu->roles()->first();
     if ($menu->role_id != null) {
         $menu->role_id = $menu->role_id->id;
     }
     $title = 'Edit Menu';
     $permissions = Permission::get()->sortBy('name');
     $roles = Role::get()->sortBy('display_name')->pluck('display_name', 'id');
     $icons = $this->icons;
     return view('profio/auth::menu.create', compact('menu', 'title', 'permissions', 'roles', 'icons'));
 }
예제 #4
0
 public function index()
 {
     $roles = Role::get()->sortBy('name');
     return view('profio/auth::role.index', compact('roles'));
 }