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


PHP Role::where方法代码示例

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


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

示例1: run

 public function run()
 {
     // create default user asset
     $asset = Asset::where('filename', '=', 'default.png')->first();
     if ($asset == NULL) {
         $asset = new Asset();
         $asset->filename = 'default.png';
         $asset->path = 'assets/content/users';
         $asset->save();
     }
     $admin = Role::where('name', '=', 'Admin')->first();
     // create default roles
     if ($admin == NULL) {
         $admin = new Role();
         $admin->name = 'Admin';
         $admin->save();
     }
     $adminUser = User::where('username', '=', 'admin')->first();
     if ($adminUser != NULL) {
         echo "Admin User Already Exsit";
     } else {
         $adminUser = new User();
         $adminUser->username = 'admin';
         $adminUser->email = 'admin@admin.com';
         $adminUser->password = 'admin';
         $adminUser->password_confirmation = 'admin';
         $adminUser->confirmation_code = md5(uniqid(mt_rand(), true));
         if ($adminUser->save()) {
             $adminUser->attachRole($admin);
             echo "Admin User Created";
         }
     }
 }
开发者ID:vanderlin,项目名称:Gear2,代码行数:33,代码来源:UserTableSeeder.php

示例2: run

 public function run()
 {
     $faker = Faker\Factory::create('es_AR');
     DB::table('users')->delete();
     //Creamos usuario generico inicial
     $id = DB::table('users')->insertGetId(array('username' => 'admin', 'password' => App::make('hash')->make('admin'), 'email' => 'admin@test.com', 'nombre' => 'ADMINISTRADOR', 'apepat' => 'TEST', 'apemat' => '', 'confirmed' => true, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")));
     $rol_id = Role::where(['name' => 'Administrador'])->first()->id;
     DB::table('assigned_roles')->insert(array('user_id' => $id, 'role_id' => $rol_id));
     foreach (range(1, 1500) as $idx) {
         if ($idx % 10 == 0) {
             echo ".";
         }
         if ($idx % 50 == 0) {
             echo " ";
         }
         if ($idx % 100 == 0) {
             echo "\n";
         }
         if ($idx % 500 == 0) {
             echo "\n";
         }
         try {
             DB::table('users')->insert(array('username' => str_ireplace(['á', 'é', 'í', 'ó', 'ú'], ['a', 'e', 'i', 'o', 'u'], mb_strtolower(str_replace(" ", "", $faker->userName))), 'password' => App::make('hash')->make($faker->word), 'email' => str_ireplace(['á', 'é', 'í', 'ó', 'ú'], ['a', 'e', 'i', 'o', 'u'], $faker->safeEmail), 'nombre' => mb_strtoupper($faker->firstName), 'apepat' => mb_strtoupper($faker->lastName), 'apemat' => mb_strtoupper($faker->lastName), 'confirmed' => true, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")));
         } catch (Exception $e) {
             //error_log($e->getMessage());
         }
     }
 }
开发者ID:ferns24,项目名称:catastro,代码行数:28,代码来源:UsersSeeder.php

示例3: store

 /**
  * Stores new account
  *
  * @return  Illuminate\Http\Response
  */
 public function store()
 {
     $repo = App::make('UserRepository');
     $user = $repo->signup(Input::all());
     if ($user->id) {
         try {
             if (Config::get('confide::signup_email')) {
                 Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
                     $message->to($user->email, $user->username)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
                 });
             }
             $role = Role::where('name', '=', 'admin')->first();
             $user->roles()->attach($role->id);
             $notice_msg = 'Su cuenta ha sido creada satisfactoriamente. Revisa tu correo';
             return Redirect::action('UsersController@login')->with('notice', $notice_msg);
         } catch (Exception $exc) {
             $userReg = User::findOrFail($user->id);
             $userReg->delete(['id']);
             return Redirect::back()->with('error', 'Falló envío de correo, intente registrarse nuevamente');
         }
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::back()->withInput(Input::except('password'))->with('error', $error);
     }
 }
开发者ID:prianticonsulting,项目名称:Habitaria,代码行数:30,代码来源:UsersController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // $inputs = Input::only(static::$createColumns);
     // $rules = static::$createValidation;
     $validator = Validator::make(Input::all(), User::$rules);
     if ($validator->fails()) {
         $messages = $validator->errors();
         return Redirect::action('UsersController@create')->withInput(Input::except('password', 'password_confirmation'))->withErrors($messages);
         // ->with('error', $error);
     } else {
         $repo = App::make('UserRepository');
         $user = $repo->signup(Input::all());
         if ($user->id) {
             if (Config::get('confide::signup_email')) {
                 Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
                     $message->to($user->email, $user->username)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
                 });
             }
             $userRole = Role::where('name', 'volunteer')->first();
             $user->attachRole($userRole->id);
             // $user->confirmed = true;
             // $user->save();
             // $result = Auth::attempt(['email' => $user->email, 'password' => Input::get('password')]);
             return Redirect::action('UsersController@create2')->with('notice', Lang::get('confide::confide.alerts.account_created'));
         } else {
             $error = $user->errors()->all(':message');
             // dd($error);
         }
         //
     }
     //closes else for validator-if
 }
开发者ID:thehelpster,项目名称:helpster,代码行数:37,代码来源:UsersController.php

示例5: run

 public function run()
 {
     DB::table('users')->delete();
     $user = User::create(array('id' => 1, 'username' => 'admin', 'first_name' => 'Yamid', 'last_name' => 'Viloria Ortega', 'email' => 'admin@admin.com', 'password' => Hash::make('1234'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
     $role = Role::where('name', '=', 'admin')->get()->first();
     $user->attachRole($role);
 }
开发者ID:ofcadavidm,项目名称:laravel-entrust,代码行数:7,代码来源:UserSeeder.php

示例6: run

 public function run()
 {
     DB::table('permissions')->delete();
     $roles = array();
     $roles[0] = Role::where('name', '=', 'admin')->first()->id;
     $roles[1] = Role::where('name', '=', 'moderator')->first()->id;
     $resources = Resource::all();
     $actions = array();
     $actions[0] = Action::where('name', '=', 'manage')->first()->id;
     /*
     $actions[0]  = Action::where('name','=','create')->first()->id;
     $actions[1]  = Action::where('name','=','read')->first()->id;
     $actions[2]  = Action::where('name','=','update')->first()->id;
     $actions[3]  = Action::where('name','=','delete')->first()->id
     */
     $data = array();
     foreach ($roles as $role) {
         foreach ($resources as $resource) {
             foreach ($actions as $action) {
                 $data[] = array('role_id' => $role, 'type' => $role == $roles[0] || $resource->name != 'role' && $resource->name != 'auth' ? 'allow' : 'deny', 'action_id' => $action, 'resource_id' => $resource->id);
             }
         }
     }
     DB::table('permissions')->insert($data);
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:25,代码来源:PermissionsTableSeeder.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if ($this->argument('name')) {
         $name = trim($this->argument('name'));
         $role = Role::where('name', '=', $name)->first();
         if ($role) {
             $this->info("Role '{$name}' already exists.");
             exit;
         }
         $role = new Role();
         $role->name = $name;
         $role->save();
         $this->info('Role saved successfully.');
     } else {
         $roles = Role::all();
         $this->info('Existing Roles:');
         foreach ($roles as $role) {
             $this->info($role->name);
         }
         $continue = $this->ask("Would you still like to add a new role? (yes/no)");
         if ('yes' === trim(strtolower($continue))) {
             $name = $this->ask("What's the new role's name?");
             $role = new Role();
             $role->name = trim($name);
             $role->save();
             $this->info('Role saved successfully.');
         }
     }
 }
开发者ID:krues8dr,项目名称:madison,代码行数:34,代码来源:CreateRole.php

示例8: run

 public function run()
 {
     $admin = Role::where('name', '=', 'administrator')->first();
     $perms = Permission::all();
     $admin->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'users manager')->first();
     $perms = Permission::where('name', '=', 'manage_users')->orWhere('name', '=', 'delete_users')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium author')->first();
     $perms = Permission::where('name', '=', 'manage_premium_casts')->orWhere('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'author')->first();
     $perms = Permission::where('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'eraser')->first();
     $perms = Permission::where('name', '=', 'delete_series')->orWhere('name', '=', 'delete_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium user')->first();
     $perms = Permission::where('name', '=', 'view_premium_casts')->orWhere('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'user')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'guest')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
 }
开发者ID:xfyuan,项目名称:xemecasts,代码行数:27,代码来源:PermissionsTableSeeder.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //1.  Create Independent Sponsor role
     $sponsorRole = Role::where('name', '=', 'Independent Sponsor')->first();
     if (!$sponsorRole) {
         $sponsorRole = new Role();
         $sponsorRole->name = "Independent Sponsor";
         $sponsorRole->save();
         $this->info("Independent Sponsor role created.");
     } else {
         $this->info("Independent Sponsor role exists.");
     }
     //2. Add Independent Sponsor role to all Admins
     $adminRole = Role::where('name', 'Admin')->first();
     $admins = $adminRole->users()->get();
     foreach ($admins as $admin) {
         $this->info('--------------------------------------------------');
         if ($admin->hasRole($sponsorRole->name)) {
             $this->info($admin->email . " already set as Independent Sponsor");
         } else {
             $admin->attachRole($sponsorRole);
             $this->info($admin->email . " set as " . $sponsorRole->name);
         }
         //3.  Remove Admin role from non-admin users
         $stayAdmin = strtolower(trim($this->ask("Keep " . $admin->email . " as an Admin? (yes/no)")));
         if ($stayAdmin != 'yes') {
             $admin->detachRole($adminRole);
             $this->info("Removed Admin role from " . $admin->email);
         } else {
             $this->info($admin->email . " still set as an Admin.");
         }
     }
 }
开发者ID:DCgov,项目名称:dc-madison,代码行数:38,代码来源:dbUpdateGroups.php

示例10: creating

 public function creating($user)
 {
     // generate activation key for the user being created
     $user->activation_key = md5(uniqid(rand(), true));
     // @TODO: use a Role repository
     $role = \Role::where('name', 'member')->first();
     $user->role()->associate($role);
 }
开发者ID:gamerwalt,项目名称:laravelsnippets,代码行数:8,代码来源:UserObserver.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $roles = $this->role->all();
     if (Request::ajax()) {
         $roles = Role::where('role', 'like', '%' . Input::get('term', '') . '%')->get(array('id', 'role'));
         return $roles;
     }
     return View::make('roles.index', compact('roles'));
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:14,代码来源:RolesController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $roles = $this->role->paginate(Settings::getValue('TABLE_ELEMENTS'));
     if (Request::ajax()) {
         $roles = Role::where('role', 'like', '%' . Input::get('term', '') . '%')->get(array('id', 'role'));
         return $roles;
     }
     return View::make('backend.roles.index', compact('roles'));
 }
开发者ID:alex-petkevich,项目名称:proweb5,代码行数:14,代码来源:RolesController.php

示例13: updateUser

 public function updateUser($id)
 {
     $user = User::find($id);
     $data = Input::all();
     $user->detachRoles($user->roles);
     $user->update($data);
     $user->attachRole(Role::where('name', $data['role'])->first());
     return Redirect::back()->with('message', 'berhasil update user');
 }
开发者ID:shittyc0de,项目名称:AplikasiLC,代码行数:9,代码来源:AdminController.php

示例14: isAdmin

 public static function isAdmin()
 {
     $role = Role::where('user_id', static::user()->id)->first();
     if ($role->permission == 1) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:nahidex,项目名称:Employee-Leave-Management-,代码行数:9,代码来源:Auth.php

示例15: getRoleId

 public static function getRoleId($rolename)
 {
     $role = Role::where('rolename', $rolename)->first();
     if ($role) {
         return $role->_id;
     } else {
         return false;
     }
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:9,代码来源:Prefs.php


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