當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::find方法代碼示例

本文整理匯總了PHP中app\Role::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::find方法的具體用法?PHP Role::find怎麽用?PHP Role::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Role的用法示例。


在下文中一共展示了Role::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $role = Role::findOrFail($id);
     $permission_role = Role::find($id)->permissions()->lists('permission_id')->toArray();
     $permissions = Permission::lists('display_name', 'id');
     return view('admin.roles.edit', compact('role', 'permissions', 'permission_role'));
 }
開發者ID:wilderguzman,項目名稱:lugrawibe,代碼行數:14,代碼來源:RolesController.php

示例2: save

 public function save(Request $request)
 {
     $input = $request->all();
     // $field_name = implode('|',$input['website']['locales']);
     $company = new Company();
     $company->name = $input['client']['company_name'];
     $company->alias = $input['website']['sub_name'];
     $company->save();
     $user = new User();
     $user->name = $input['client']['name'];
     $user->email = $input['client']['email'];
     $user->password = $input['client']['password'];
     $user->ip = '*';
     $user->branch_id = 1;
     $user->company_id = $company->id;
     $user->active = 1;
     $user->save();
     $user->roles()->attach(Role::find(1)->id);
     // $gr_fields = new GrFields;
     // $gr_fields->field_name = $field_name;
     // $gr_fields->company_id = $company->id;
     // $gr_fields->save();
     session(['input' => $input]);
     return redirect('thanks');
 }
開發者ID:sahilbhatt92,項目名稱:transpt,代碼行數:25,代碼來源:CompanyController.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $usuario = User::find($id);
     $role = Role::all();
     $rol = Role::find($id);
     return view('users/show')->with('usuario', $usuario)->with('role', $role)->with('rol', $rol);
 }
開發者ID:ehgarcia25,項目名稱:DebeHaber,代碼行數:13,代碼來源:UsuarioController.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = Role::find($id);
     $role->name = Input::get('name');
     $role->save();
     return Redirect::route('template.role.index');
 }
開發者ID:jumaya,項目名稱:redbpim,代碼行數:13,代碼來源:RolesController.php

示例5: postSearch

 public function postSearch(Request $request)
 {
     if (!$request->name and !$request->email) {
         $models = User::paginate(10);
     }
     if ($request->name) {
         $models = User::where('name', 'like', '%' . $request->name . '%')->paginate(10);
     }
     if ($request->email) {
         $models = User::where('email', 'like', '%' . $request->email . '%')->paginate(10);
     }
     if ($request->name and $request->email) {
         $models = User::where('name', 'like', '%' . $request->name . '%')->where('email', 'like', '%' . $request->email . '%')->paginate(10);
     }
     if ($request->role_list) {
         $models = Role::find($request->role_list)->users()->paginate(10);
     }
     if ($request->role_list and $request->name) {
         $models = Role::find($request->role_list)->users()->where('name', 'like', '%' . $request->name . '%')->paginate(10);
     }
     if ($request->role_list and $request->email) {
         $models = Role::find($request->role_list)->users()->where('email', 'like', '%' . $request->email . '%')->paginate(10);
     }
     if ($request->role_list and $request->email and $request->name) {
         $models = Role::find($request->role_list)->users()->where('name', 'like', '%' . $request->name . '%')->where('email', 'like', '%' . $request->email . '%')->paginate(10);
     }
     $model = new User();
     $model->name = $request->name;
     $model->email = $request->email;
     $model->role_list = $request->role_list;
     $roles = Role::lists('name', 'id');
     $roles[''] = 'нет';
     return view('admin.user.index', compact('models', 'model', 'roles'));
 }
開發者ID:Ravend6,項目名稱:laravel_base_v5.2,代碼行數:34,代碼來源:UserController.php

示例6: run

 public function run()
 {
     $this->command->info('Seeding permission to role associations.');
     $permissions = Permission::get()->modelKeys();
     // Insert default permissions.
     foreach ($this->slugs() as $role_id => $slugs) {
         foreach ($slugs as $slug_key => $slug_value) {
             if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
                 $permission_id = $slug_key;
                 $permission_value = !!$slug_value;
             } else {
                 $permission_id = $slug_value;
                 $permission_value = true;
             }
             if (in_array($permission_id, $permissions)) {
             } else {
                 $this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
             }
         }
     }
     // Give admin permissions.
     if (count($permissions)) {
         $role = Role::find(Role::ID_ADMIN);
         $role->permissions()->detach();
         $attachments = [];
         foreach ($permissions as $permission_id) {
             $attachments[] = ['permission_id' => $permission_id, 'value' => 1];
         }
         $role->permissions()->attach($attachments);
     }
 }
開發者ID:JEWSbreaking8chan,項目名稱:infinity-next,代碼行數:31,代碼來源:RoleSeeder.php

示例7: validateMerchantOtp

 public function validateMerchantOtp(request $request)
 {
     $apiKey = $request->only('api_key');
     $validator = Validator::make($apiKey, ['api_key' => 'required']);
     if ($validator->fails()) {
         $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
         return $response;
     }
     $role = Role::find(2);
     $key = Config::get('custom.JWTkey');
     $decoded = JWT::decode($apiKey['api_key'], $key, array('HS256'));
     if ($decoded->type != 'merchant') {
         return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
     }
     $user = User::find($decoded->sub);
     // check the current user
     if (empty($user) || !$user->hasRole(['merchant']) || !$user->status) {
         return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
     }
     $user_id = $user->id;
     $input = $request->only('otp');
     $matchThese = ['user_id' => $user_id, 'code' => $input['otp']];
     $sms = UserSmsCode::where($matchThese)->first();
     if ($sms == '' || empty($sms)) {
         return response()->json(['response_code' => 'RES_IOG', 'messages' => 'Invalid OTP Given'], 422);
     }
     $sms->status = true;
     $sms->save();
     $user->is_mobile_verified = true;
     $user->save();
     return response()->json(['response_code' => 'RES_MV', 'messages' => 'Mobile Verified']);
 }
開發者ID:abhilash698,項目名稱:projectK,代碼行數:32,代碼來源:ValidateMobileController.php

示例8: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $permissions = Permission::all();
     $role = Role::find($id);
     $permission_role = $role->r_permission;
     return View('role.edit', compact('role', 'permissions', 'permission_role'));
 }
開發者ID:adit33,項目名稱:inventory,代碼行數:13,代碼來源:RoleController.php

示例9: desasignar

 public function desasignar()
 {
     $rol = Role::find(Input::get('role_id'));
     $rolPermisos = RolesPermission::where('role_id', '=', Input::get('role_id'))->where('permission_id', '=', Input::get('permission_id'))->get()->first();
     $desasignar = RolesPermission::destroy($rolPermisos->id);
     return Response::json('ok');
 }
開發者ID:jumaya,項目名稱:redbpim,代碼行數:7,代碼來源:PermissionController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     // Validate the forum
     $this->validate($request, ['name' => 'required|unique:forums|max:255', 'description' => 'required']);
     // Create a new Forum
     $forum = new Forum();
     $forum->name = $request->name;
     $forum->slug = str_slug($request->name, '-');
     $forum->description = $request->description;
     if ($forum->save()) {
         // Grant the admin access to the forum
         $admin = Role::find(1);
         // Admin should be created when built, shouldn't be an issue
         $accessForum = new Permission();
         $accessForum->name = 'access-forum-' . $forum->id;
         $accessForum->display_name = 'Access ' . $forum->name;
         // optional
         $accessForum->description = 'Ability to access and post in ' . $forum->name;
         // optional
         $accessForum->save();
         $admin->attachPermission($accessForum);
         Session::flash('alert-success', 'Forum created.');
     } else {
         Session::flash('alert-error', 'Could not create forum.');
     }
     return redirect('dashboard');
 }
開發者ID:unbolt,項目名稱:imp,代碼行數:33,代碼來源:ForumController.php

示例11: getDelete

 public function getDelete($role_id)
 {
     $role = Role::find($role_id);
     $user_role_name = User::getUserRoleName();
     $users = User::getUsersFromRoleId($role_id);
     return view('admin.roles.delete', compact('role'))->with(compact('user_role_name'))->with('related_users_count', $users->count());
 }
開發者ID:hydrosolutions,項目名稱:irrigation-calculator,代碼行數:7,代碼來源:RoleController.php

示例12: addPermissionToGroup

 public function addPermissionToGroup(Request $request)
 {
     $permission = Permission::find($request->permission_id);
     $role = Role::find($request->role_id);
     $role->attachPermission($permission);
     Session::flash('alert-success', 'Permission Granted');
     return back();
 }
開發者ID:unbolt,項目名稱:imp,代碼行數:8,代碼來源:GroupController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     // Add dev account until we enable registration
     $newUser = App\User::create(['name_first' => "Developer", 'name_last' => "EditMe", "affiliation_id" => 1, "email" => "developer@codeforcharlotte.org", 'password' => Hash::make('admin'), 'nomination_limit' => 5, 'active' => 'Y']);
     $role = \App\Role::find(1);
     $newUser->attachRole($role);
 }
開發者ID:CodeForCharlotte,項目名稱:cmpd-holiday-gift-backend,代碼行數:13,代碼來源:ProductionUsersTableSeeder.php

示例14: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     //dd($permissions);
     $role = Role::find(4);
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $user->roles()->attach($role);
     return $user;
 }
開發者ID:bychems,項目名稱:projet-pfe,代碼行數:14,代碼來源:AuthController.php

示例15: update

 public function update(Request $request, $id)
 {
     $name = Input::get('e_name');
     $role = Role::find($id);
     $role->nombre = $name;
     $role->save();
     return Redirect::route('roles.index');
 }
開發者ID:danielrolonbenitez,項目名稱:vertical,代碼行數:8,代碼來源:RolesController.php


注:本文中的app\Role::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。