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


PHP Role::find方法代码示例

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


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

示例1: signup

 /**
  * Signup a new account with the given parameters
  *
  * @param  array $input Array containing 'username', 'email' and 'password'.
  *
  * @return  User User object that may or may not be saved successfully. Check the id to make sure.
  */
 public function signup($input)
 {
     $user = new User();
     $user->username = md5(uniqid(mt_rand(), true));
     $user->email = array_get($input, 'email');
     $user->password = array_get($input, 'password');
     $myRole = array_get($input, 'myrole');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $user->password_confirmation = array_get($input, 'password_confirmation');
     // Generate a random confirmation code
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     // Save if valid. Password field will be hashed before save
     $user->save();
     if ($GLOBALS['APP-MAILING'] == false) {
         $user->confirmed = 1;
         $user->save();
     }
     // Add Role
     if ($user->id) {
         $role = Role::find($myRole);
         $user->roles()->attach($role);
     }
     return $user;
 }
开发者ID:birdiebel,项目名称:G2016,代码行数:33,代码来源:UserRepository.php

示例2: initialize

 public function initialize($user, $role)
 {
     $this->add(new Text("userName", array('placeholder' => '*Nombre de usuario', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Password("pass", array('placeholder' => '*Contraseña', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Password("pass2", array('placeholder' => '*Repita la contraseña', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Email("email", array('placeholder' => '*Email', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text("name_user", array('placeholder' => '*Nombre', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text("lastName", array('placeholder' => '*Apellido', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text("address_user", array('placeholder' => '*Dirección', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Select('state_user', array('' => '*Seleccionar Departamento', 'AMAZONAS' => 'AMAZONAS', 'ANTIOQUIA' => 'ANTIOQUIA', 'ARAUCA' => 'ARAUCA', 'ATLANTICO' => 'ATLANTICO', 'BOLIVAR' => 'BOLIVAR', 'BOYACA' => 'BOYACA', 'BOYACA' => 'BOYACA', 'CALDAS' => 'CALDAS', 'CAQUETA' => 'CAQUETA', 'CASANARE' => 'CASANARE', 'CAUCA' => 'CAUCA', 'CESAR' => 'CESAR', 'CHOCO' => 'CHOCO', 'CORDOBA' => 'CORDOBA', 'CUNDINAMARCA' => 'CUNDINAMARCA', 'GUAINIA' => 'GUAINIA', 'GUAJIRA' => 'GUAJIRA', 'GUAVIARE' => 'GUAVIARE', 'HUILA' => 'HUILA', 'MAGDALENA' => 'MAGDALENA', 'META' => 'META', 'NARIÑO' => 'NARIÑO', 'NTE_SANTANDER' => 'NORTE DE SANTANDER', 'PUTUMAYO' => 'PUTUMAYO', 'QUINDIO' => 'QUINDIO', 'RISARALDA' => 'RISARALDA', 'SAN_ANDRES' => 'SAN ANDRES Y PROVIDENCIA', 'SANTANDER' => 'SANTANDER', 'SUCRE' => 'SUCRE', 'TOLIMA' => 'TOLIMA', 'VALLE' => 'VALLE DEL CAUCA', 'VAUPES' => 'VAUPES', 'VICHADA' => 'VICHADA')));
     $this->add(new Select('city_user', array()));
     $this->add(new Text("phone_user", array('placeholder' => '*Teléfono', 'required' => 'required', 'class' => 'form-control')));
     $roles = Role::find();
     $r = array();
     if ($role->name == 'sudo') {
         foreach ($roles as $rol) {
             $r[$rol->idRole] = $rol->name;
         }
     } else {
         foreach ($roles as $rol) {
             if ($rol->name != 'sudo') {
                 $r[$rol->idRole] = $rol->name;
             }
         }
     }
     $this->add(new Select('idRole', $r, array('placeholder' => '*Funciones', 'required' => 'required', 'class' => 'form-control select2')));
 }
开发者ID:dorianlopez,项目名称:track,代码行数:27,代码来源:UserForm.php

示例3: 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('roles.index');
 }
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:13,代码来源:RolesController.php

示例4: getAcl

 public function getAcl()
 {
     //if (!isset($this->persistent->acl)) {
     $acl = new Phalcon\Acl\Adapter\Memory();
     $acl->setDefaultAction(Phalcon\Acl::DENY);
     //Register roles
     $rol = Role::find(array("cache" => array("key" => "role")));
     foreach ($rol as $ros) {
         $roles[strtolower($ros->name)] = new Phalcon\Acl\Role($ros->name);
     }
     foreach ($roles as $role) {
         $acl->addRole($role);
     }
     foreach (Action::find(array("cache" => array("key" => "action"))) as $actions) {
         $acl->addResource(new Phalcon\Acl\Resource($actions->controller->name), $actions->name);
     }
     //Grant access to public areas to both users and guests
     foreach ($rol as $role) {
         foreach ($role->action as $action) {
             $roledann[$role->name][$action->controller->name][] = $action->name;
         }
     }
     // print_r($roledann);
     foreach ($roledann as $keys => $dann) {
         foreach ($dann as $key => $dan) {
             $acl->allow($keys, $key, $dan);
         }
     }
     //The acl is stored in session, APC would be useful here too
     //$this->persistent->acl = $acl;
     //	}
     //return $this->persistent->acl;
     return $acl;
 }
开发者ID:qtebest-dev,项目名称:tractor,代码行数:34,代码来源:Security.php

示例5: 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:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:7,代码来源:PermissionsController.php

示例6: initialize

 public function initialize($user, $thuser)
 {
     $roles = Role::find();
     $r = array();
     if ($thuser->idRole == 1) {
         foreach ($roles as $rol) {
             $r[$rol->idRole] = $rol->name;
         }
     } else {
         foreach ($roles as $rol) {
             if ($rol->name != 'sudo') {
                 $r[$rol->idRole] = $rol->name;
             }
         }
     }
     $this->add(new Select('idRole', $r, array('required' => 'required', 'class' => 'select2 select')));
     $this->add(new Check('status', array('type' => 'checkbox', 'class' => 'bootstrap-switch')));
     $this->add(new Text('email', array('maxlength' => 100, 'type' => 'email', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text('userName', array('maxlength' => 40, 'type' => 'text', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Password('password1', array('maxlength' => 50, 'type' => 'text', 'required' => 'password', 'class' => 'form-control')));
     $this->add(new Password('password2', array('maxlength' => 50, 'type' => 'password', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text('name', array('maxlength' => 40, 'type' => 'text', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text('lastName', array('maxlength' => 40, 'type' => 'text', 'required' => 'required', 'class' => 'form-control')));
     $this->add(new Text('phone', array('maxlength' => 50, 'type' => 'text', 'class' => 'form-control')));
 }
开发者ID:solutionsCluster,项目名称:silar,代码行数:25,代码来源:UserForm.php

示例7: store

 /**
  * Store a newly created resource in storage.
  * POST /users
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, User::$rules);
     if ($validation->passes()) {
         DB::transaction(function () {
             $user = new User();
             $user->first_name = strtoupper(Input::get('first_name'));
             $user->middle_initial = strtoupper(Input::get('middle_initial'));
             $user->last_name = strtoupper(Input::get('last_name'));
             $user->dept_id = Input::get('department');
             $user->confirmed = 1;
             $user->active = 1;
             $user->email = Input::get('email');
             $user->username = Input::get('username');
             $user->password = Input::get('password');
             $user->password_confirmation = Input::get('password_confirmation');
             $user->confirmation_code = md5(uniqid(mt_rand(), true));
             $user->image = "default.png";
             $user->save();
             $role = Role::find(Input::get('name'));
             $user->roles()->attach($role->id);
         });
         return Redirect::route('user.index')->with('class', 'success')->with('message', 'Record successfully added.');
     } else {
         return Redirect::route('user.create')->withInput(Input::except(array('password', 'password_confirmation')))->withErrors($validation)->with('class', 'error')->with('message', 'There were validation errors.');
     }
 }
开发者ID:jcyanga28,项目名称:project-reference,代码行数:35,代码来源:UsersController.php

示例8: destroy

 public static function destroy($id)
 {
     $role = Role::find($id);
     $role->destroy();
     flash('Role removed successfully!');
     Redirect::to('/roles');
 }
开发者ID:KristianLauttamus,项目名称:HospitalSchedule,代码行数:7,代码来源:RolesController.php

示例9: run

 public function run()
 {
     $faker = Faker::create();
     Permission::truncate();
     DB::table('permission_role')->truncate();
     Permission::create(['action' => 'User.create']);
     Permission::create(['action' => 'User.view']);
     Permission::create(['action' => 'User.update']);
     Permission::create(['action' => 'User.delete']);
     Permission::create(['action' => 'Category.create']);
     Permission::create(['action' => 'Category.view']);
     Permission::create(['action' => 'Category.update']);
     Permission::create(['action' => 'Category.delete']);
     Permission::create(['action' => 'Post.create']);
     Permission::create(['action' => 'Post.view']);
     Permission::create(['action' => 'Post.update']);
     Permission::create(['action' => 'Post.delete']);
     Permission::create(['action' => 'Comment.create']);
     Permission::create(['action' => 'Comment.view']);
     Permission::create(['action' => 'Comment.update']);
     Permission::create(['action' => 'Comment.delete']);
     Permission::create(['action' => 'Role.create']);
     Permission::create(['action' => 'Role.view']);
     Permission::create(['action' => 'Role.update']);
     Permission::create(['action' => 'Role.delete']);
     Permission::create(['action' => 'Permission.create']);
     Permission::create(['action' => 'Permission.view']);
     Permission::create(['action' => 'Permission.update']);
     Permission::create(['action' => 'Permission.delete']);
     $admin = Role::find(1);
     $admin->permissions()->sync(range(1, 24));
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:32,代码来源:PermissionsTableSeeder.php

示例10: storeUser

 public function storeUser()
 {
     $validator = Validator::make($data = Input::all(), User::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $user = new User();
     $user->username = $data['username'];
     $user->email = $data['email'];
     $user->password = $data['password'];
     $user->password_confirmation = $data['password_confirmation'];
     if (isset($data['tipe'])) {
         $user->tipe = $data['tipe'];
         $user->nama = $data['nama'];
         $user->alamat = $data['alamat'];
         $user->telp = $data['telp'];
     }
     $user->confirmed = 1;
     $user->save();
     if ($data['role'] == '0') {
         $user->attachRole(Role::find(6));
     } elseif ($data['role'] == '1') {
         $user->attachRole(Role::find(3));
     } elseif ($data['role'] == '2') {
         $user->attachRole(Role::find(4));
         $outlet = new Outlet();
         $outlet->user_id = $user->id;
         $name = 'Outlet ' . $user->username . '';
         $outlet->name = $name;
         $outlet->save();
     }
     return Redirect::to('admin/users')->with('message', 'berhasil menambahkan user');
 }
开发者ID:shittyc0de,项目名称:AplikasiLC,代码行数:33,代码来源:AdminController.php

示例11: initialize

 public function initialize($entity = null, $options = null)
 {
     $role = new Select('roleid', Role::find(), array('using' => array('id', 'role'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un Rol')));
     $role->setLabel('Rol');
     $this->add($role);
     //añadimos un botón de tipo submit
     $submit = $this->add(new Submit('Guardar', array('class' => 'btn btn-success')));
 }
开发者ID:andresfranco,项目名称:Phalcontest,代码行数:8,代码来源:UserRoleForm.php

示例12: getRoleAttribute

 public function getRoleAttribute()
 {
     if ($this->role_id == '0') {
         return 'Няма';
     } else {
         return Role::find($this->role_id)->name;
     }
 }
开发者ID:mertindervish,项目名称:registerbg,代码行数:8,代码来源:Invitation.php

示例13: find

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function find($id)
 {
     $model = Role::find($id);
     if ($model) {
         return $model;
     }
     return 'Role not found.';
 }
开发者ID:dasigr,项目名称:laravelcommerce,代码行数:14,代码来源:RoleRepository.php

示例14: delete

 public function delete()
 {
     //check if the role already exist...
     $id = Input::get('id');
     $role = Role::find($id);
     $role->delete();
     return Response::jsend('success', array('msg' => 'Role successfully deleted.'));
 }
开发者ID:SystechTechnologies,项目名称:hrms-laravel,代码行数:8,代码来源:RoleController.php

示例15: delete

 public function delete($id)
 {
     $role = Role::find($id);
     $role->delete();
     // redirect
     Session::flash('message', 'Successfully deleted the role!');
     return Redirect::to('admin/role');
 }
开发者ID:elioth010,项目名称:carretilla_online,代码行数:8,代码来源:RoleController.php


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