public function run()
 {
     DB::table('users')->delete();
     DB::table('groups')->delete();
     DB::table('users_groups')->delete();
     Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'System', 'last_name' => 'Admin', 'activated' => 1));
     Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1)));
     Sentry::getGroupProvider()->create(array('name' => 'User', 'permissions' => array('user' => 1)));
     // Assign user permissions
     $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**');
     $adminGroup = Sentry::getGroupProvider()->findByName('Admin');
     $adminUser->addGroup($adminGroup);
 }
 public function postStore()
 {
     $name = Input::get('name');
     $admin = Input::get('admin') == 'yes' ? 1 : 0;
     $user = Input::get('user') == 'yes' ? 1 : 0;
     try {
         // Create the group
         $group = Sentry::getGroupProvider()->create(array('name' => $name, 'permissions' => array('admin' => $admin, 'users' => $user)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         return 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         return 'Group already exists';
     }
     return Redirect::to('admin/groups');
 }
 public function postStore()
 {
     $id = Input::get('id');
     /*
      * Validate
      */
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'password' => 'required|confirmed|min:6');
     $validation = Validator::make(Input::all(), $rules);
     if (!$validation->passes()) {
         if (isset($id)) {
             return Redirect::to('admin/users/edit/' . $id)->withErrors($validation)->withInput();
         } else {
             return Redirect::to('admin/users/create')->withErrors($validation)->withInput();
         }
     }
     $first_name = Input::get('first_name');
     $last_name = Input::get('last_name');
     $email = Input::get('email');
     $password = Input::get('password');
     $role = Input::get('role');
     $activated = Input::get('activated') == 'yes' ? 1 : 0;
     try {
         // Create the user
         $user = Sentry::getUserProvider()->create(array('email' => $email, 'password' => $password, 'first_name' => $first_name, 'last_name' => $last_name, 'activated' => $activated));
         // Find the group using the group id
         $adminGroup = Sentry::getGroupProvider()->findById($role);
         // Assign the group to the user
         $user->addGroup($adminGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         return 'User with this login already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         return 'Group was not found.';
     }
     return Redirect::to('admin/users');
 }