当前位置: 首页>>代码示例>>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;未经允许,请勿转载。