当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::where方法代码示例

本文整理汇总了PHP中app\Role::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::where方法的具体用法?PHP Role::where怎么用?PHP Role::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Role的用法示例。


在下文中一共展示了Role::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     // assign member role
     $member = \App\Role::where('name', 'member')->first();
     $user->attachRole($member);
     return $user;
 }
开发者ID:nmfzone,项目名称:pesantren,代码行数:14,代码来源:AuthController.php

示例2: post

 public function post(Step2Request $request)
 {
     // if id is found, update advisor
     if ($advisor_id = $request->input('id')) {
         $advisor = Advisor::find($advisor_id);
         $advisor->update($request->all());
     } else {
         // create new advisor
         $advisor = new Advisor($request->all());
         $advisor->school_id = Session::get('school')->id;
         $advisor->event_id = Session::get('event')->id;
         $advisor->save();
     }
     Session::set('advisor', Advisor::find($advisor->id));
     if (!$request->input('other_school')) {
         // auto create first advisor
         $attendee = new Attendee();
         // split up the attending advisor name
         $attendee_name = explode(' ', $request->input('attending_advisor'));
         if (is_array($attendee_name) && count($attendee_name) > 1) {
             $attendee->first_name = $attendee_name[0];
             $attendee->last_name = $attendee_name[1];
         } else {
             $attendee->first_name = $request->input('attending_advisor');
             $attendee->last_name = '';
         }
         $attendee->event_id = Session::get('event')->id;
         $attendee->school_id = Session::get('school')->id;
         $attendee->role_id = Role::where(['name' => 'Advisor', 'event_id' => Session::get('event')->id])->first()->id;
         $attendee->advisor_id = Session::get('advisor')->id;
         $attendee->save();
         Flash::info(trans('notifications.edit_as_needed'));
     }
     return redirect('/event/' . Session::get('event')->slug . '/step/3');
 }
开发者ID:Hipp04,项目名称:registered-solutions,代码行数:35,代码来源:Step2Controller.php

示例3: edit

 public function edit($id)
 {
     $role_id = Users::find($id)->role_id;
     $role_name = App\Role::where('id', '=', $role_id)->value('role_name');
     $roles = App\Role::all()->toArray();
     $allRole = array();
     foreach ($roles as $role) {
         $allRole[] = $role;
     }
     $result = Users::find($id);
     $password = Users::find($id)->value('password');
     $listStatus = "";
     if ($result['status'] == 1) {
         $listStatus .= '<option value = "1" selected> Actived</option >';
         $listStatus .= '<option value = "0" > Not Active </option >';
     } else {
         $listStatus .= '<option value = "1" > Actived</option >';
         $listStatus .= '<option value = "0" selected> Not Active </option >';
     }
     $listRole = "";
     foreach ($allRole as $role) {
         if ($role_id == $role['id']) {
             $listRole .= '<option value = "' . $role_id . '" selected >' . $role_name . '</option >';
         } else {
             $listRole .= '<option value = "' . $role['id'] . '" >' . $role['role_name'] . '</option >';
         }
     }
     return view('admin.users.edit', compact('result'))->with(['password' => $password, 'listStatus' => $listStatus, 'listRole' => $listRole]);
 }
开发者ID:dhduc,项目名称:shopui,代码行数:29,代码来源:UsersController.php

示例4: run

 public function run()
 {
     DB::table('users')->delete();
     User::create(['name' => 'Anonymous', 'password' => Hash::make('')]);
     $user = User::create(['name' => 'Steven Barnett', 'email' => 'steven.abarnett@gmail.com', 'password' => Hash::make('reedsmetals')]);
     $user->roles()->save(Role::where('name', 'SuperAdmin')->first());
     $user->save();
     $user = User::create(['name' => 'Stephanie Barnett', 'email' => 'stephanie.e.white@gmail.com', 'password' => Hash::make('1')]);
     $user->roles()->save(Role::where('name', 'SuperAdmin')->first());
     $user->save();
     $user = User::create(['name' => 'Anna Hays', 'email' => 'ah.graphicdesign@live.com', 'password' => Hash::make('reedsmetals')]);
     $user->roles()->save(Role::where('name', 'Developer')->first());
     $user->save();
     require 'employeeSeed.php';
     foreach ($employees as $employeeName => $employeeInfo) {
         if ($employeeInfo['email'] != null) {
             $user = User::create(['name' => $employeeName, 'email' => $employeeInfo['email'], 'password' => Hash::make('reedsmetals')]);
             foreach ($employeeInfo['roles'] as $role) {
                 $user->roles()->save(Role::where('name', $role)->first());
             }
             $user->save();
             echo "Created user: " . $employeeName . "\n";
         }
     }
 }
开发者ID:stevendesu,项目名称:reedsmetals.com,代码行数:25,代码来源:UserTableSeeder.php

示例5: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $role_user = \App\Role::where('role', '=', 'user')->first();
     $user->roles()->attach($role_user);
     return $user;
 }
开发者ID:anthon94,项目名称:p4,代码行数:13,代码来源:AuthController.php

示例6: setUserIdAttribute

 /**
  * Override setting the user_id attribute to automatically adjust user roles.
  * @param $value
  */
 public function setUserIdAttribute($value)
 {
     // Only process the change in permissions
     // if the assigned user has changed
     $old_id = $this->getAttributeValue('user_id');
     if ($old_id != $value) {
         // Don't allow self-unassignment
         if ($old_id == Auth::user()->id) {
             Flash::warning('You can\'t remove yourself from the committee');
             return;
         }
         // Get the necessary roles
         $committee = Role::where('name', 'committee')->first();
         $member = Role::where('name', 'member')->first();
         // Look through the database for any other committee roles for
         // the old user. If they exist then we don't want to remove
         // their committee permissions.
         $old_user = User::find($old_id);
         if ($old_user && $old_user->hasRole($committee->name)) {
             if (CommitteeRole::where('user_id', '=', $old_user->id)->where('id', '<>', $this->id)->get()->count() == 0) {
                 $old_user->detachRole($committee);
                 $old_user->attachRole($member);
             }
         }
         // Always give the new user committee permissions
         $new_user = User::find($value);
         if ($new_user && !$new_user->hasRole($committee->name)) {
             $new_user->attachRole($committee);
             $new_user->detachRole($member);
         }
     }
     // Set the new id
     $this->attributes['user_id'] = $value;
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:38,代码来源:CommitteeRole.php

示例7: getRoleAttribute

 public function getRoleAttribute()
 {
     if ($this->roles->isEmpty()) {
         $this->attachRole(Role::where('name', '=', 'Narys')->get()->first());
     }
     return $this->roles->first();
 }
开发者ID:Bebrazmogis,项目名称:maze-ap,代码行数:7,代码来源:User.php

示例8: run

 /**
  * Run the database seeds.
  * @return void
  */
 public function run()
 {
     // Add the user
     $user_su2bc = User::create(["username" => "su2bc", "email" => "su2bc@bath.ac.uk", "password" => bcrypt(env("SU2BC_PWD")), "forename" => "Super", "surname" => "Admin", "status" => true], false);
     // Add the permissions
     $user_su2bc->roles()->save(Role::where('name', 'super_admin')->first());
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:11,代码来源:UserTableSeeder.php

示例9: revokeReport

 public function revokeReport($report)
 {
     if (is_string($report)) {
         $report = Role::where('key', $report)->first();
     }
     return $this->reports()->detach($report);
 }
开发者ID:sopoisun,项目名称:narotser-hadni-kodnop,代码行数:7,代码来源:Account.php

示例10: store

 /**
 * Method Name :Store
 * Insert data to User Table and consequencesly insert to Account, Carries and Downline table
 *
 *
 */
 public function store(UserRegRequest $request, User $user)
 {
     $uplineUser = User::where('username', $request->upline_id)->first();
     $referrarUser = User::where('username', $request->referrar_id)->first();
     $uplineId = $uplineUser->id;
     $requestValue = $request->placement;
     // return $request->full_name . "++". preg_replace('/\s+/', '', strtolower($request->username));
     // $username =
     $address = $request->address1 . "," . $request->address2;
     // return
     $user->insert([['username' => preg_replace('/\\s+/', '', strtolower($request->username)), 'full_name' => $request->full_name, 'gender' => $request->gender, 'email' => $request->email, 'password' => bcrypt($request->password), 'remember_token' => $request->_token, 'address' => $address, 'phone_number' => $request->phone_number, 'country' => $request->country, 'account_no' => 555210, 'referrar_id' => $referrarUser->id, 'upline_id' => $uplineUser->id, 'pin' => rand(1, 99999999), 'signup_date' => Carbon::now(), 'last_login_time' => Carbon::now()]]);
     $lastRegUser = $user->where('username', preg_replace('/\\s+/', '', strtolower($request->username)))->first();
     $role = Role::where('id', 3)->first();
     $lastRegUser->assign($role);
     Account::insert(['balance' => 0, 'roi_balance' => 0, 'user_id' => $lastRegUser->id, 'acc_type' => '0']);
     Carry::insert(['user_id' => $lastRegUser->id, 'left_carry' => 0, 'right_carry' => 0, 'matching_qualify' => 0]);
     Downline::insert(['user_id' => $lastRegUser->id, 'left_member_id' => 0, 'right_member_id' => 0]);
     /*Downline::where('user_id', $uplineUser->id)
       ->update(['right_member_id' => $request->placement]);*/
     /*return $downLineTable = Downline::where('user_id', $uplineId)->first();
       if($downLineTable->left_member_id == 0 && $request->placement != 'right'){
                   Downline::where('user_id', $uplineUser->id)
                               ->update(['left_member_id' => $lastRegUser->id]);  
               }
       else
               {
                  Downline::where('user_id', $uplineUser->id)
                   ->update(['right_member_id' => $lastRegUser->id]); 
               }
               */
     $position = preg_replace('/\\s+/', '', strtolower($requestValue)) . "_member_id";
     Downline::where('user_id', $uplineUser->id)->update([$position => $lastRegUser->id]);
     return redirect()->back();
 }
开发者ID:rintosarkar,项目名称:capital,代码行数:40,代码来源:UserController.php

示例11: run

 /**
  * Run the database seeds.
  */
 public function run()
 {
     //初始化系统默认 Role
     foreach (['销售', '售后', '产品', '硬件'] as $name) {
         $role = Role::where('name', $name)->first();
         if (!$role) {
             $role = new Role();
         }
         $role->name = $name;
         $role->system = true;
         $role->save();
     }
     //销售权限设定
     $role = Role::where('name', '销售')->first();
     $role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '客户信息管理', '项目签约', '项目信息管理', '项目模块管理', '项目参数管理', '项目硬件管理', '项目服务器管理'];
     $role->save();
     //售后权限设定
     $role = Role::where('name', '售后')->first();
     $role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '项目信息管理', '项目模块管理', '项目参数管理', '项目硬件管理', '项目服务器管理', '服务器信息管理', '项目文件管理', '项目外出记录管理', '项目硬件部署管理'];
     $role->save();
     //产品权限设定
     $role = Role::where('name', '产品')->first();
     $role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '产品信息管理', '产品类别管理', '产品模块管理', '产品参数管理', '服务器信息管理'];
     $role->save();
     //硬件权限设定
     $role = Role::where('name', '硬件')->first();
     $role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '硬件管理'];
     $role->save();
 }
开发者ID:genee-projects,项目名称:snail,代码行数:32,代码来源:InitRoles.php

示例12: revokeRole

 public function revokeRole($role)
 {
     if (is_string($role)) {
         $role = Role::where('name', $role)->first();
     }
     return $this->roles()->detach($role);
 }
开发者ID:sopoisun,项目名称:narotser-hadni-kodnop,代码行数:7,代码来源:User.php

示例13: editUser

 public function editUser(EditUserRequest $request)
 {
     $user = User::where('username' == Input::get('name'))->first();
     $role = Role::where('name' == Input::get('name'));
     $user->assignRole($role);
     return redirect('/admin');
 }
开发者ID:mathewsandi,项目名称:MafiaGame,代码行数:7,代码来源:AdminController.php

示例14: checkRoleInheritance

 protected function checkRoleInheritance(User $user = null, $roleName)
 {
     //未登入直接不通過
     if (!$user) {
         return false;
     }
     //直接擁有該角色
     if ($user->hasRole($roleName)) {
         return true;
     }
     //檢查角色是否存在
     $role = Role::where('name', $roleName)->first();
     if (!$role) {
         return false;
     }
     //檢查擁有的角色,是否繼承欲檢查之角色
     $roleList = $user->roles;
     foreach ($roleList as $roleItem) {
         if (isset(static::$inheritance[$roleItem->name]) || array_key_exists($roleItem->name, static::$inheritance)) {
             //繼承表有該角色
             $roleInheritanceList = static::$inheritance[$roleItem->name];
             if (is_array($roleInheritanceList)) {
                 foreach ($roleInheritanceList as $roleInheritance) {
                     if ($roleInheritance = $role->name) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:alhs1995,项目名称:DBFP,代码行数:32,代码来源:RoleLimit.php

示例15: register

 public function register()
 {
     $enabled_registrations = [2, 3];
     $confirmation_code = str_random(30);
     $data = ['name' => Input::get('name'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'role_id' => Input::get('role_id'), User::MOBILE_NUMBER => Input::get('mobile_number', NULL), User::DESCRIPTION => Input::get('description', NULL), User::IMAGE => Input::get('image', NULL), User::BIRTH_DATE => Input::get('birth_date', NULL), User::GENDER => Input::get('gender', NULL), 'confirmation_code' => $confirmation_code];
     if (!in_array($data['role_id'], $enabled_registrations)) {
         return "Invalid role";
     }
     if ($this->validator($data)) {
         $data = array_filter($data, 'strlen');
         $user = User::create($data);
         $user->roles()->attach($data['role_id']);
         $role = Role::where('name', 'Expert')->select(['id'])->first();
         if (!is_null($role)) {
             $role_id = $role->id;
             if ($role_id == $data['role_id']) {
                 $user_extra = $this->insertExtra($user->id);
                 //to be implemented
                 // mail has to be sent to the admin all details of the newly signed up expert.
                 $data = ["first_name" => isset($user_extra->first_name) && $user_extra->first_name != NULL ? $user_extra->first_name : "not available", "last_name" => isset($user_extra->last_name) && $user_extra->last_name != NULL ? $user_extra->last_name : "not available", "personal_email" => isset($user_extra->personal_email) && $user_extra->personal_email != NULL ? $user_extra->personal_email : "not available", "highest_degree" => isset($user_extra->highest_degree) && $user_extra->highest_degree != NULL ? $user_extra->highest_degree : "not available", "major_specialization" => isset($user_extra->major_specialization) && $user_extra->major_specialization != NULL ? $user_extra->major_specialization : "not available", "profession" => isset($user_extra->profession) && $user_extra->profession != NULL ? $user_extra->profession : "not available", "expert_area" => isset($user_extra->expert_area) && $user_extra->expert_area != NULL ? $user_extra->expert_area : "not available", "linkedin_url" => isset($user_extra->linkedin_url) && $user_extra->linkedin_url != NULL ? $user_extra->linkedin_url : "not available", "research_gate_id" => isset($user_extra->research_gate_id) && $user_extra->research_gate_id != NULL ? $user_extra->research_gate_id : "not available", "facebook_url" => isset($user_extra->facebook_url) && $user_extra->facebook_url != NULL ? $user_extra->facebook_url : "not available", "resume_url" => isset($user_extra->resume_url) && $user_extra->resume_url != NULL ? $user_extra->resume_url : "not available", "email" => isset($user->email) && $user->email != NULL ? $user->email : "not available", "mobile_number" => isset($user->mobile_number) && $user->mobile_number != NULL ? $user->mobile_number : "not available", "description" => isset($user->description) && $user->description != NULL ? $user->description : "not available", "gender" => isset($user->gender) && $user->gender != NULL ? $user->gender : "not available", "birth_date" => isset($user->birth_date) && $user->birth_date != NULL ? $user->birth_date : "not available", "image" => isset($user->image) && $user->image != NULL ? $user->image : "not available"];
                 Mail::send('email.email_to_admin', $data, function ($message) {
                     $message->to("tamyworld@gmail.com", "Admin")->subject('New Expert Registration');
                 });
             } else {
                 $this->dispatch(new SendRegistrationEmail($user));
             }
         }
         return "Registration Successfull";
     } else {
         return "Validation Error";
     }
 }
开发者ID:Scaledesk,项目名称:gritwings,代码行数:32,代码来源:RegistrationController.php


注:本文中的app\Role::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。