/** * Execute the console command. * * @return mixed */ public function handle() { $this->info("Clearing permissions... \n"); // Delete old data $response = Action::deleteAllData(); null !== $response ? $this->error("\n" . $response . "\n") : null; $this->info("Permissions cleared... \n"); try { $routeData = $this->getRouteData(); $roles = Role::all(); DB::beginTransaction(); foreach ($routeData as $action => $uri) { $action = new Action(['uri' => $uri, 'action' => $action]); $action->save(); $this->savePermissions($roles, $action); $this->comment("Added action " . $action->action . "\n"); } $cache = $this->getCacheInstance(['permissions']); $cache->flush(); DB::commit(); } catch (\Exception $e) { DB::rollBack(); $this->error("\n" . $e->getMessage() . "\n"); } }
public function roles($id) { $this->authorize('user_view_roles'); $user = User::find($id); $roles = Role::all(); return view('admin.users.roles', compact('user', 'roles')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(User $User) { $this->data['Roles'] = Role::all(); $this->data['Groups'] = Group::all(); $this->data['User'] = $User; return view('admin.users.edit', $this->data); }
/** * Returns a new form for the specified user. * * @param User $user * * @return \Orchestra\Contracts\Html\Builder */ public function form(User $user) { return $this->form->of('users', function (FormGrid $form) use($user) { if ($user->exists) { $method = 'PATCH'; $url = route('admin.users.update', [$user->getKey()]); $form->submit = 'Save'; } else { $method = 'POST'; $url = route('admin.users.store'); $form->submit = 'Create'; } $form->attributes(compact('method', 'url')); $form->with($user); $form->fieldset(function (Fieldset $fieldset) use($user) { $fieldset->control('input:text', 'name')->attributes(['placeholder' => 'Enter the users name.']); $fieldset->control('input:text', 'email')->attributes(['placeholder' => 'Enter the users email address.']); if ($user->exists) { $fieldset->control('input:select', 'roles[]')->label('Roles')->options(function () { return Role::all()->pluck('label', 'id'); })->value(function (User $user) { return $user->roles->pluck('id'); })->attributes(['class' => 'select-roles', 'multiple' => true]); } $fieldset->control('input:password', 'password')->attributes(['placeholder' => 'Enter a password to change the users password.']); $fieldset->control('input:password', 'password_confirmation')->attributes(['placeholder' => 'Enter the users password again.']); }); }); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $user = User::find($id); $role = Role::find($user->type); $roles = Role::all(); return view('user.edit', compact('user', 'role', 'roles')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $roles = Role::all(); $permissions = Permission::all(); $usersWithRoles = User::with('roles')->orderBy('last_name')->get(); return view('admin.roles.index', ['roles' => $roles, 'permissions' => $permissions, 'users' => $usersWithRoles]); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return mixed */ public function edit($id) { $availableAppointment = AvailableAppointment::findOrFail($id); $fixtures = Fixture::all(); $roles = Role::all(); return view('admin.data-management.available-appointments.edit', compact('availableAppointment', 'fixtures', 'roles')); }
public function getAllRoles($relationships = null) { if (isset($relationships)) { return Role::with($relationships)->get(); } return Role::all(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $permissions = $this->getAllActions(); $actions = $this->getRouteData(); $roles = Role::all(); // Add new actions foreach ($actions as $action => $uri) { if (!array_key_exists($action, $permissions)) { $newAction = new Action(['action' => $action, 'uri' => $uri]); $newAction->save(); $this->savePermissions($roles, $newAction); $this->info("Added " . $action . "\n"); } else { unset($permissions[$action]); } } // Remove non existing actions foreach ($permissions as $action => $uri) { Action::where(['action' => $action, 'uri' => $uri])->first()->destroy(); $this->comment("Removed " . $action . "\n"); } $cache = $this->getCacheInstance(['permissions']); $cache->flush(); $this->info("Done. \n"); }
/** * Add user page * * @return response */ public function edit($id) { $roles = ['' => _t('backend_user_select_role')]; foreach (Role::all() as $role) { $roles[$role->id] = $role->name; } return view('backend::user.form', ['user' => $this->_getUserById($id), 'roles' => $roles]); }
public function getEdit($id) { $roles = []; foreach (Role::all() as $role) { $roles[$role->id] = $role->title; } return view('admin.users.details', ['user' => User::find($id), 'roles' => $roles]); }
public static function allConPermisos($detailed = false) { $roles = Role::all(); foreach ($roles as $rol) { $rol->perms = $rol->permissions($detailed); } return $roles; }
/** * Get dropdown of all roles available for user * * @return mixed */ public function getRolesDropdownOptions() { $allRoles = Role::all(); foreach ($allRoles as $eachRole) { $results[$eachRole->id] = $eachRole->custom_role_name; } return $results; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $auths = Models\Role::find(12)->auths; // foreach($auths as $auth){ // echo $auth->auth_name; // } return view('admin.role.index')->withRoles(Models\Role::all()); }
/** * Show the application registration form. * * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed */ public function getRegister() { // Prepare dropdown for roles $allRoles = Role::all(); foreach ($allRoles as $eachRole) { $rolesOptions[$eachRole->id] = $eachRole->custom_role_name; } $viewHtml = view('pages.main.user', ['mode' => 'register', 'user' => '', 'rolesOptions' => $rolesOptions, 'rolesSelectedOptions' => ''])->render(); return response()->json(["viewBody" => $viewHtml]); }
public function GetRolePermissionView() { if (Auth::check()) { if (User::isSuperAdmin()) { $role_obj = Role::all(); return view('user.role_permission_list')->with('role_obj', $role_obj)->with('permission', \Permission_Check::getPermission()); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } return Redirect::to(url('user/login')); }
/** * Handle search page * * @param Request $request * @return \Illuminate\View\View */ public function getSearch(Request $request) { $search = $request->input('search'); $roles = Role::all(); try { $actions = Action::search($this->search($search, ['proximity' => false, 'fuzzy' => 0.1, 'phrase' => false])); $data = ['actions' => $actions->get(), 'roles' => $roles, 'search' => $search, 'uri' => 'admin/permissions', 'title' => trans('temp.search_results')]; } catch (\Exception $e) { $data = ['actions' => [], 'roles' => $roles, 'search' => $search, 'uri' => 'admin/permissions', 'title' => trans('temp.search_results')]; } return view('admin.permissions.all', $data); }
public function get_editable() { $functions = Functions::all(); $role = Role::all(); $inputRole = "<select id='col3' class='small m-wrap' tabindex='1'>"; foreach ($role as $roles) { $inputRole = $inputRole . '<option value=' . $roles->id . '>' . $roles->name . '</option>'; } $inputRole = $inputRole . "</select>"; Log::info($inputRole); return view('example.table_editable', ['functions' => $functions, 'inputRole' => $inputRole]); }
public function edit($id) { $admin = Admin::with(['role'])->find($id); //dd($admin->role); if (!$admin->role->isEmpty()) { $role_id = $admin->role[0]->id; } else { $role_id = 0; } $roles = Role::all(); $roles = $this->toOptionArray($roles); return view($this->view_path . 'edit', compact('admin', 'roles', 'role_id')); }
public function getEdit($id) { if (!$this->hasPermission('edit.user')) { return response()->view('errors.401', [], 401); } if ($this->user->id == $id) { return redirect('/user/myaccount/' . $id); } $roles = Role::all(); $user = User::find($id); list($permissions, $values) = array_divide($user->permissions); return view('user.edit', compact('user', 'roles', 'permissions')); }
/** * Affiche une liste de rôle. * * @return Response */ public function index() { try { $roles = Role::all()->sortby('nom'); foreach ($roles as $role) { if ($role->description == "") { $role->description = "Aucune description"; } } } catch (ModelNotFoundException $e) { App::abort(404); } return View::make('roles.index', compact('roles')); }
/** * Saving the mapping for user to role assignment * * @return Response */ public function saveUserRoleAssignment() { $arrayUserRoleMapping = Input::get('userRoles'); $users = User::all(); $roles = Role::all(); foreach ($users as $userkey => $user) { foreach ($roles as $roleKey => $role) { //If checkbox is clicked attach the role if (!empty($arrayUserRoleMapping[$userkey][$roleKey])) { $user->attachRole($role); } elseif (empty($arrayUserRoleMapping[$userkey][$roleKey])) { $user->detachRole($role); } } } $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('terms.record-successfully-updated')); }
function viewcMenu() { $user = Auth::admin()->user(); $roles = Role::all(); foreach ($roles as $value) { if ($user->hasRole($value->name)) { $dataPermission = Permission::join('permission_role as p', 'permissions.id', '=', 'p.permission_id')->select('permissions.*')->where('p.role_id', '=', $value->id)->get()->toArray(); foreach ($dataPermission as $value) { if ($user->can($value['name'])) { $menu[] = ['name' => $value['description'], 'modulo' => $value['modulo'], 'controller' => $value['name']]; } else { echo "<script language='JavaScript'>history.back(alert('No tienes acceso para esta pagina'));</script>"; exit; } } return $menu; } } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(PermissionRequest $request) { $arrayPermissionRoleMapping = $request->permissionRoles; $permissions = Permission::all(); $roles = Role::all(); foreach ($permissions as $permissionkey => $permission) { foreach ($roles as $roleKey => $role) { //If checkbox is clicked attach the permission if (!empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) { // check that this permission has not already been attached to a role before attempting it again! if (!$role->perms->find($permission->id)) { $role->attachPermission($permission); } } elseif (empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) { $role->detachPermission($permission); } } } return redirect()->to('permission.index')->with('message', trans_choice('messages.record-successfully-saved', 1))->with('active_permission', $permission->id); }
public function run() { $regions = Region::all(); $roles = Role::all(); $items = [["Gates", "Bill", 14, 1, 1, 0, "2000-01-23", "123 rue Delatortue", "819-472-5555", "*****@*****.**"], ["Jobs", "Steve", 13, 2, 1, 0, "1980-06-28", "456 rue Dulapin", "819-473-5555", "*****@*****.**"]]; DB::table('delegues')->delete(); foreach ($items as $item) { $delegue = new Delegue(); $delegue->nom = $item[0]; $delegue->prenom = $item[1]; $delegue->region_id = $regions[$item[2]]->id; $delegue->role_id = $roles[$item[3]]->id; $delegue->accreditation = $item[4]; $delegue->sexe = $item[5]; $delegue->date_naissance = $item[6]; $delegue->adresse = $item[7]; $delegue->telephone = $item[8]; $delegue->courriel = $item[9]; $delegue->save(); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { if ($result = check_auth_to('YHLB_EDIT')) { return $result; } $data['roleList'] = Role::all(); $data['userInfo'] = User::find($id); return view('admin.user.edit', $data); }
public function role() { $title = 'Role'; $breadcrumb = array(array('Home', 0), array('User', 0), array('Roles', 1)); $css = $this->CSS('users'); $jH = $this->jS('roles'); $result = Role::all(); $a = 0; $footer = Setting::where('name', 'footer')->get(); if (count($footer) > 0) { $footer = $footer->first()->value; } else { $footer = '(c) Ordent ' . date('Y'); } $sB = $this->getPermission('1'); $sBa = $this->getDefault(); $sBe = $this->getDefault(); $sBd = $this->getDefault(); return view('backend.role', compact('css', 'jH', 'title', 'result', 'a', 'breadcrumb', 'footer', 'sB')); }
public function getRoles() { try { $response = []; $statusCode = 200; $guest = \App\Models\Role::all(); foreach ($guest as $a) { $response[] = ['id' => $a->id, 'value' => $a->role]; } } catch (Exception $e) { $statusCode = 404; } finally { return Response::json($response, $statusCode); } }
public function index() { // show all $records = Role::all(); return $records; }
/** * @param Role $role * @param Country $country * @param Age $age * @return mixed */ public function showRegistrationForm(Role $role, Country $country, Age $age) { $param = collect(); return view('web.users.create', compact('param'))->with('roles', $role->all())->with('countries', $country->all())->with('ages', $age->all()); }