當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。