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


PHP Role::whereId方法代碼示例

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


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

示例1: destroy

 public function destroy($id)
 {
     $role = Role::whereId($id)->first();
     $role->delete();
     alert()->success('...', 'Rôle supprimé !')->autoclose(3500);
     return redirect('/entrust/roles');
 }
開發者ID:decalages,項目名稱:ct-base,代碼行數:7,代碼來源:RolesController.php

示例2: it_checks_if_a_user_has_at_least_one_out_of_a_collection_of_roles

 /** @test */
 public function it_checks_if_a_user_has_at_least_one_out_of_a_collection_of_roles()
 {
     $user = factory(User::class)->create();
     $role_1 = factory(Role::class)->create(['name' => 'role1', 'display_name' => 'Role1']);
     $role_2 = factory(Role::class)->create(['name' => 'role2', 'display_name' => 'Role2']);
     $user->addRole($role_2);
     $this->assertTrue($user->hasRole(Role::all()));
     $this->assertFalse($user->hasRole(Role::whereId($role_1->id)->get()));
 }
開發者ID:guenthertheilen,項目名稱:laravel-boilerplate,代碼行數:10,代碼來源:UserTest.php

示例3: update

 public function update($id)
 {
     $role = Role::whereId($id)->firstOrFail();
     $input = Input::all();
     $rules = array('name' => 'required', 'display_name' => 'required');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
     } else {
         $role->name = Input::get('name');
         $role->display_name = Input::get('display_name');
         $role->description = Input::get('description');
         $role->save();
         return Response::json(['success' => true, 'message' => 'The role has been updated!']);
     }
 }
開發者ID:keung725,項目名稱:shop,代碼行數:16,代碼來源:RolesController.php

示例4: getDefaultRole

 public static function getDefaultRole()
 {
     $defaultRoleId = Option::getValueByKey('default_role_id');
     $defaultRole = Role::whereId($defaultRoleId)->first();
     if (!$defaultRole) {
         throw new SystemException(SystemException::DefaultRoleNotDefined);
     }
     return $defaultRole;
 }
開發者ID:lialosiu,項目名稱:amaoto-core,代碼行數:9,代碼來源:System.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     if (\Auth::user()->roles[0]->can('menu-update')) {
         $input = $request->all();
         $input['url'] = "admin/" . str_plural(Str::lower($input['name'] != 'Dashboard' ? $string = str_replace(" ", "_", $input['name']) : ''));
         $menu = $this->menus->findOrFail($id);
         $menu->update($input);
         $menu->roles()->detach();
         foreach ($request->roles as $_id) {
             $role = Role::whereId($_id)->first();
             $menu->assign($role);
         }
         \Session::flash('flash_message', 'Menu updated!');
         return \Redirect::route('admin.menus.index', [])->withMessage(trans('acl::menu.menus-controller-successfully_updated'));
     }
     return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
 }
開發者ID:meccado,項目名稱:acl-admin-control-panel,代碼行數:24,代碼來源:MenuController.php


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