/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (\Auth::user()->roles[0]->can('menu-read')) { $items = $this->menus->with('roles')->where('parent_id', '=', '0')->orderBy('sort_order', 'ASC')->get(); return \View::make('acl::admin.menus.index', ['items' => $items, 'title' => 'list']); } return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access')); }
/** * @param string $order_by * @param string $sort * @param bool $withPermissions * @return mixed */ public function getAllRoles($order_by = 'id', $sort = 'asc', $withPermissions = false) { if ($withPermissions) { return Role::with('permissions')->orderBy($order_by, $sort)->get(); } return Role::orderBy($order_by, $sort)->get(); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $this->authorize('roles-edit'); $role = Role::with('permissions')->findOrFail($id); $permissions = Permission::orderBy('display_name')->get(); return view('roles.edit', compact('permissions', 'role')); }
public function update_role(Request $request) { /* Delete existing role */ Role::where('id', $request->role_id_to_remove)->delete(); if ($request->user_id) { /* Add new role/user */ $role = new Role(); $role->booking_id = $request->booking_id; $role->role_type_id = $request->role_type_id; $role->user_id = $request->user_id; $role->save(); /* write to changes */ $user_name = User::where('id', $request->user_id)->first()->name; $change = array('booking_id' => $request->booking_id, 'change_type_id' => 1, 'user_id' => Auth::user()->id, 'from' => null, 'to' => $user_name); Change::create($change); $newRole = Role::with('role_type', 'user')->where('id', $role->id)->first(); return $newRole; } return; }
public function role() { $roles = Role::with('perms')->get(); $perms = Permission::orderBy('name')->get(); $roles_json = $roles->toArray(); $data = compact('roles', 'perms', 'roles_json'); // dd($data); return view('user.role', $data); }
/** * Store given permissions to role. * * @param \Illuminate\Http\Request $request * * @return void */ public function postGiveRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->givePermissionTo($permission); } Session::flash('flash_message', 'Permission granted!'); return redirect('admin/roles'); }
/** * Store given permissions to role. * * @param \Illuminate\Http\Request $request * * @return void */ public function postUserRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->assign($permission); } \Session::flash('flash_message', 'Permission granted!'); return \Redirect::route('admin.assign-role-permissions', []); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $validator = Validator::make($request->all(), ['name' => 'required', 'display' => 'required'], ['name.required' => 'Nama Role tidak boleh kosong.', 'display.required' => 'Alias tidak boleh kosong.']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $role = Role::with('permissions')->find($id); $inPermission = $request->get('permissions') != "" ? $request->get('permissions') : []; $rolePermission = array_column($role->permissions->toArray(), 'id'); if ($role->update($request->all())) { // for new permissions $newPermission = array_diff($inPermission, $rolePermission); if (count($newPermission)) { $role->addPermission($newPermission); } // for delete permissions $deletePermission = array_diff($rolePermission, $inPermission); if (count($deletePermission)) { $role->removePermission($deletePermission); } return redirect('/user/role')->with('succcess', 'Sukses ubah role.'); } return redirect()->back()->withErrors(['failed' => 'Gagal ubah role.']); }
public function getEffectivePermission() { if ($this->effectivePermission != null) { return $this->effectivePermission; } else { $role = \App\Role::with('permission')->find($this->getRoleId()); if ($role != null) { $this->effectivePermission = $role->permission; } else { $this->effectivePermission = array(); } return $this->effectivePermission; } }
public function getStaff() { $staff = []; $roles = Role::with('users')->where('board_uri', $this->board_uri)->get(); $roles = []; foreach ($this->roles as $role) { foreach ($role->users as $user) { $staff[$user->user_id] = $user; if (!isset($roles[$user->user_id])) { $roles[$user->user_id] = []; } $roles[$user->user_id][] = $role; } } foreach ($roles as $user_id => $role) { $staff[$user_id]->setRelation('roles', collect($role)); } return $staff; }
public function getStaff() { $staff = []; $roles = Role::with('users')->where('board_uri', $this->board_uri)->get(); foreach ($this->roles as $role) { foreach ($role->users as $user) { $staff[$user->user_id] = $user; } } return $staff; }
public function index() { $roles = Role::with('permissions')->get(); return view('admin.roles.index', compact('roles')); }
/** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { $users = $this->users->with('roles')->get(); return \View::make('admin.users.index', ['users' => $users, 'title' => 'list']); }
/** * Index */ public function index() { return Role::with('permissions')->get(); }
public function getRoles() { return Role::with('users')->get(); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\View\View */ public function show($id) { $role = Role::with('permissions')->findOrFail($id); return \View::make('admin.roles.show', compact('role')); }
public function copysc(Request $request, $id) { $episode = Episode::find($id, ['id', 'drama_id', 'title']); $drama = Drama::find($episode->drama_id, ['title']); $src = Episode::find($request->input('src'), ['id', 'title']); $roles = Role::with(['sc' => function ($query) { $query->select('id', 'name'); }])->select('id', 'sc_id', 'job', 'note')->where('episode_id', $src->id)->orderBy('job')->get(); return view('episode.copysc', ['episode' => $episode, 'drama' => $drama, 'src' => $src, 'roles' => $roles]); }
/** * API for retrieving roles */ public function apiRoles() { return Role::with('permissions')->get(); }
public function index() { $roles = Role::with('perms')->paginate(10); return view('admin.role.index', ['roles' => $roles]); }
public function show(Request $request, $id) { $sc = Sc::find($id, ['id', 'name', 'alias', 'club_id', 'jobs', 'information', 'reviews']); $sc->load(['club' => function ($query) { $query->select('id', 'name'); }]); $roles = Role::with(['drama' => function ($query) { $query->select('id', 'title'); }, 'episode' => function ($query) { $query->select('id', 'title'); }])->select('drama_id', 'episode_id', 'job', 'note')->where('sc_id', $id)->orderBy('id', 'desc')->take(10)->get(); $reviews = Screv::with(['user' => function ($query) { $query->select('id', 'name'); }])->select('id', 'user_id', 'title', 'content', 'created_at')->where('model_id', $id)->where('model', 0)->orderBy('id', 'desc')->take(20)->get(); if (Auth::check()) { $userReviews = Screv::select('id', 'title', 'content', 'created_at')->where('user_id', $request->user()->id)->where('model_id', $id)->where('model', 0)->get(); } else { $userReviews = 0; } return view('sc.show', ['sc' => $sc, 'roles' => $roles, 'reviews' => $reviews, 'userReviews' => $userReviews]); }
public function sc($id) { $drama = Drama::find($id, ['id', 'title']); $episodes = Episode::select('id', 'title')->where('drama_id', $id)->orderByRaw('release_date, id')->get(); $roles = Role::with(['sc' => function ($query) { $query->select('id', 'name'); }])->select('id', 'episode_id', 'sc_id', 'job', 'note')->where('drama_id', $id)->orderBy('job')->get(); $roles = $roles->groupBy('episode_id'); return view('drama.sc', ['drama' => $drama, 'episodes' => $episodes, 'roles' => $roles]); }
public function editRole($id) { $role = Role::with('permissions')->findOrFail($id); $permissions = Permission::get(['id', 'name']); return view('admin.users.editrole', compact('role', 'permissions')); }