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


PHP Sentry::findGroupById方法代码示例

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


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

示例1: store

 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $validator = Validator::make($data = Input::all(), User::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     try {
         // Create the user
         $user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'phone' => $data['phone'], 'activated' => true));
         // Find the group using the group id
         $group = Sentry::findGroupById($data['group']);
         // Assign the group to the user
         $user->addGroup($group);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
     return Redirect::route('users.index');
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:32,代码来源:UsersController.php

示例2: store

 public function store()
 {
     $v = Validator::make($data = Input::all(), User::$rules);
     if ($v->fails()) {
         return Response::json(array($v->errors()->toArray()), 500);
         // return Response::json(array('flash' => 'Something went wrong, try again !'), 500);
     } else {
         $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
         if (Input::hasFile('picture')) {
             $uploaded_picture = Input::file('picture');
             // mengambil extension file
             $extension = $uploaded_picture->getClientOriginalExtension();
             // membuat nama file random dengan extension
             $filename = md5(time()) . '.' . $extension;
             $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img/photos';
             // memindahkan file ke folder public/img/photos
             $uploaded_picture->move($destinationPath, $filename);
             // mengisi field picture di user dengan filename yang baru dibuat
             $user->picture = $filename;
             $user->save();
         }
         // Find the similiar group
         $GroupId = Sentry::findGroupById(Input::get('group_id'));
         // Insert user user into specified group
         $user->addGroup($GroupId);
         return Response::json(array('flash' => 'New user has been successfully created !'), 200);
     }
 }
开发者ID:yevta,项目名称:simple-crm-laravel,代码行数:28,代码来源:UserController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|min:4|max:254|email', 'password' => 'required|min:6|confirmed', 'password_confirmation' => 'required', 'group' => 'required');
     $validator = Validator::make($input, $rules);
     if ($validator->passes()) {
         $result = array();
         try {
             $user = \Sentry::register(array('email' => $input['email'], 'password' => $input['password'], 'first_name' => $input['first_name'], 'last_name' => $input['last_name']));
             $group = \Sentry::findGroupById($input['group']);
             $user->addGroup($group);
             $this->mailer->welcome($user);
             $result['success'] = true;
             $result['message'] = 'Activation code is sent , please check your email';
         } catch (Exception\LoginRequiredException $e) {
             $result['success'] = false;
             $result['message'] = 'Login field is required.';
         } catch (Exception\PasswordRequiredException $e) {
             $result['success'] = false;
             $result['message'] = 'Password field is required.';
         } catch (Exception\UserExistsException $e) {
             $result['success'] = false;
             $result['message'] = 'User with this login already exists';
         }
         return Redirect::route('users.index')->with('message', $result['message']);
         //return Redirect::route('users.index')->with('message','Successfully Registered');
     }
     return Redirect::route('users.create')->withInput()->withErrors($validator);
 }
开发者ID:arikazukitomaharjan,项目名称:OfficeSystem,代码行数:34,代码来源:UserController.php

示例4: save

 public function save()
 {
     if (Request::ajax() && Request::isMethod('post')) {
         try {
             $input = Input::all();
             $valid = Validator::make($input, ['username' => 'required', 'email' => 'required|email', 'full_name' => 'required']);
             if ($valid->fails()) {
                 throw new Exception('Todos los campos son obligatorios');
             }
             if (empty($input['id'])) {
                 $group = Sentry::findGroupById($input['group']);
                 $user = Sentry::createUser(['username' => $input['username'], 'email' => $input['email'], 'full_name' => $input['full_name'], 'password' => $input['password_confirmation'], 'activated' => !empty($input['activated']) ? 1 : 0]);
                 $user->addGroup($group);
             } else {
                 $user = Sentry::findUserById($input['id']);
                 $user->email = $input['email'];
                 $user->full_name = $input['full_name'];
                 $user->activated = !empty($input['activated']) ? 1 : 0;
                 $user->save();
             }
             return Response::json(URL::route('admin.users'), 200);
         } catch (Exception $e) {
             return Response::json($e->getMessage(), 400);
         }
     }
 }
开发者ID:eldalo,项目名称:jarvix,代码行数:26,代码来源:UsersController.php

示例5: update

 public function update($id)
 {
     try {
         // Find the user using the user id
         $user = Sentry::findUserById($id);
         $user->last_name = Input::get('last_name');
         $user->activated = Input::get('activated');
         // Update the user
         if ($user->save()) {
             $userGroups = $user->groups()->lists('group_id');
             $selectedGroups = array(Input::get('group'));
             $groupsToAdd = array_diff($selectedGroups, $userGroups);
             $groupsToRemove = array_diff($userGroups, $selectedGroups);
             foreach ($groupsToAdd as $groupId) {
                 $group = Sentry::findGroupById($groupId);
                 $user->addGroup($group);
             }
             foreach ($groupsToRemove as $groupId) {
                 $group = Sentry::findGroupById($groupId);
                 $user->removeGroup($group);
             }
             // User information was updated
         } else {
             // User information was not updated
         }
         return Redirect::route('admin.users.index');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         return Redirect::back()->withInput()->withErrors('User with this login already exists.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->withErrors('User was not found.');
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:32,代码来源:UsersController.php

示例6: postDenegarpermiso

 public function postDenegarpermiso($idgrupo, $permiso)
 {
     $sentryGroups = \Sentry::findGroupById($idgrupo);
     $permisos = $sentryGroups->getPermissions();
     $permisos[$permiso] = 0;
     $sentryGroups->permissions = $permisos;
     $sentryGroups->save();
     return \Response::json(array('mensaje' => 'Se denego el permiso correctamente.'));
 }
开发者ID:richarrieta,项目名称:miequipo,代码行数:9,代码来源:GruposController.php

示例7: permissions

 public static function permissions($id, $name_permissions)
 {
     $group = Sentry::findGroupById($id);
     foreach ($group->getPermissions() as $name => $activated) {
         if ($name_permissions == $name && $activated == 1) {
             return True;
         }
     }
 }
开发者ID:hectorz11,项目名称:laravel_sistema_art,代码行数:9,代码来源:User.php

示例8: testRetrieveGroupByName

 public function testRetrieveGroupByName()
 {
     // Find the group we will use for reference
     $reference = Sentry::findGroupById(1);
     // This is the code we are testing
     $group = $this->repo->retrieveByName($reference->name);
     // Assertions
     $this->assertInstanceOf('Sentinel\\Models\\Group', $group);
     $this->assertEquals(1, $group->id);
 }
开发者ID:matheusgomes17,项目名称:Sentinel-1,代码行数:10,代码来源:SentryGroupRepositoryTests.php

示例9: destroy

 public function destroy($id)
 {
     try {
         $group = Sentry::findGroupById($id);
         $group->delete();
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
     return Redirect::route('admin.group.index')->with("successMessage", "Data berhasil dihapus ");
 }
开发者ID:inseo201,项目名称:simkinerja,代码行数:10,代码来源:GroupController.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //创建用户组
     Sentry::createGroup(array('name' => 'Admin', 'is_admin' => 1, 'permissions' => []));
     Sentry::createGroup(array('name' => 'Guest', 'is_admin' => 0, 'permissions' => []));
     $user = Sentry::createUser(array('email' => 'admin@admin.com', 'username' => 'admin', 'password' => '123456', 'activated' => true));
     $adminGroup = Sentry::findGroupById(1);
     $user->addGroup($adminGroup);
     Uinfo::create(['uid' => $user->id]);
 }
开发者ID:leebivip,项目名称:laravel_cmp,代码行数:15,代码来源:SentryInitSeeder.php

示例11: run

 public function run()
 {
     DB::table('users')->delete();
     DB::table('groups')->delete();
     DB::table('users_groups')->delete();
     $user = Sentry::createUser(array('username' => 'superadmin', 'password' => 'ad123min', 'first_name' => 'Super', 'last_name' => 'Administrator', 'activated' => 1));
     $group = Sentry::createGroup(array('name' => 'Super Administrators', 'permissions' => array('superuser' => 1)));
     // Assign user permissions
     $userGroup = Sentry::findGroupById(1);
     $user->addGroup($userGroup);
 }
开发者ID:ratno,项目名称:Doptor,代码行数:11,代码来源:SentrySeeder.php

示例12: createSuperuser

 /**
  * Create new random superuser.
  *
  * @param string $password
  *
  * @return \VisualAppeal\Connect\User
  */
 protected function createSuperuser($password = '123456')
 {
     $lastLogin = $this->faker->dateTime();
     $admin = \Sentry::createUser(['email' => $this->faker->email, 'password' => $password, 'activated' => 1, 'activated_at' => $this->faker->dateTime($lastLogin), 'last_login' => $lastLogin, 'first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName]);
     try {
         $adminGroup = Sentry::findGroupById(1);
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         $adminGroup = Sentry::createGroup(['name' => 'Superuser', 'permissions' => ['superuser' => 1]]);
     }
     $admin->addGroup($adminGroup);
     return $admin;
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:19,代码来源:TestCase.php

示例13: postUpdate

 /**
  * Admin.group.update
  */
 public function postUpdate($id = null)
 {
     // Set permission
     Auth::requirePermissions('admin.group.update');
     try {
         if (empty($id)) {
             $id = \Input::get('id');
         }
         // Find the user using the group id
         $group = \Sentry::findGroupById($id);
         $permissions_save = \Input::get('btn_save_permissions');
         if (empty($permissions_save)) {
             // Update group
             if ($id > 2) {
                 $group->name = \Input::get('name');
             }
             $group->save();
         } else {
             if ($group->id > 2) {
                 // Update permissions
                 $permission_data = \Input::get();
                 $permissions = array();
                 // Unset previous permissions
                 $group_permissions = $group->getPermissions();
                 foreach ($group_permissions as $p => $value) {
                     $permissions[$p] = 0;
                 }
                 // Add new ones
                 foreach ($permission_data as $p => $value) {
                     // Skip extra information
                     if ($p == 'id' || $p == 'btn_save_permissions') {
                         continue;
                     }
                     // Form undo transform
                     $p = str_replace('_', '.', $p);
                     // Permission set
                     $permissions[$p] = 1;
                 }
                 // Save permissions
                 $group->permissions = $permissions;
                 $group->save();
             }
         }
     } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
         Flash::set('Name is required');
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         // Ignore and redirect back
     } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         // Ignore and redirect back
     }
     return \Redirect::to('api/admin/groups');
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:55,代码来源:GroupController.php

示例14: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     /*create the first user as super admin*/
     $user = Sentry::createUser(array('email' => 'amitavroy@gmail.com', 'password' => 'test1234', 'activated' => true, 'first_name' => 'Amitav', 'last_name' => 'Roy'));
     $group = Sentry::createGroup(array('name' => 'Super Admin', 'permissions' => array('create_users' => 1, 'edit_users' => 1, 'delete_users' => 1, 'manage_users' => 1, 'manage_permissions' => 1)));
     $adminGroup = Sentry::findGroupById(1);
     $user->addGroup($adminGroup);
     /*create second user as admin*/
     $user = Sentry::createUser(array('email' => 'jhon.doe@gmail.com', 'password' => 'test1234', 'activated' => true, 'first_name' => 'Jhon', 'last_name' => 'Doe'));
     $group = Sentry::createGroup(array('name' => 'Administrator', 'permissions' => array('create_users' => 1, 'edit_users' => 1, 'delete_users' => 0, 'manage_users' => 0, 'manage_permissions' => 0)));
     $adminGroup = Sentry::findGroupById(2);
     $user->addGroup($adminGroup);
     $group = Sentry::createGroup(array('name' => 'Authenticated User'));
 }
开发者ID:l4mod,项目名称:sentryuser,代码行数:19,代码来源:2014_07_17_013906_create_default_users.php

示例15: create_post

 public function create_post()
 {
     $validator = Validator::make(Input::all(), User::get_rules());
     if ($validator->fails()) {
         return Redirect::to('admin/clients/create')->withErrors($validator)->withInput();
     } else {
         $user = Sentry::createUser(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'tin_number' => Input::get('tin_number'), 'landline' => Input::get('landline'), 'mobile' => Input::get('mobile'), 'work_address' => json_endcode(explode(",", Input::get('work_address'))), 'home_address' => json_endcode(explode(",", Input::get('home_address'))), 'company' => Input::get('company'), 'occupation' => Input::get('occupation'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => true));
         // Find the group using the group id
         $group = Sentry::findGroupById(1);
         // Assign the group to the user
         $user->addGroup($group);
         return Redirect::to('admin/clients')->with('success', 'Client account has been successfully created.');
     }
 }
开发者ID:jacobDaeHyung,项目名称:Laravel-Real-Estate-Manager,代码行数:14,代码来源:ClientsController.php


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