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