/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required|alpha_dash|unique:roles,name', 'permissions' => 'required');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->save();
         // Save permissions
         $this->role->savePermissions($inputs['permissions']);
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/roles/messages.create.success'));
         }
         // Redirect to the new role page
         return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/roles/messages.create.error'));
         // Redirect to the role create page
         return Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('admin/roles/messages.' . $error));
     }
     // Form validation failed
     return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Declare the rules for the form validation
     $rules = array('name' => 'required');
     $getPermissions = Input::get('permissions');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->save();
         // Save permissions
         $perms = $this->permission->get();
         if (count($perms)) {
             if (isset($getPermissions)) {
                 $this->role->perms()->sync($this->permission->preparePermissionsForSave($getPermissions));
             }
         }
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/roles/messages.create.success'));
         }
         // Redirect to the new role page
         return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/roles/messages.create.error'));
         // Redirect to the role create page
         return Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('admin/roles/messages.' . $error));
     }
     // Form validation failed
     return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
 }
 public function setUp()
 {
     parent::setUp();
     $this->role = Role::getNewInstance('__testrole__');
     $this->role->save();
     $this->userGroup = UserGroup::getNewInstance('Any random group name');
     $this->userGroup->save();
 }
Esempio n. 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Validate the inputs
     $rules = array('name' => 'required|alpha_dash|unique:roles,name', 'description' => 'required');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->description = $inputs['description'];
         $this->role->save($rules);
         if ($this->role->id) {
             // Save permissions
             $this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
             // Redirect to the new role page
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/role/messages.create.success'));
         } else {
             // Redirect to the role create page
             //var_dump($this->role);
             return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/role/messages.create.error'));
         }
     } else {
         // Form validation failed
         return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
     }
 }
 public function run()
 {
     $user = new User();
     $user->email = '*****@*****.**';
     $user->username = '******';
     $user->password = Hash::make('secret');
     $user->password_confirmation = $user->password;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->email . '" <' . $user->email . '>');
     }
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $user = new User();
     $user->email = '*****@*****.**';
     $user->username = '******';
     $user->password = Hash::make('secret');
     $user->password_confirmation = $user->password;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->email . '" <' . $user->email . '>');
     }
     $user = User::where('username', $user->username)->firstOrFail();
     $user->attachRole($admin);
 }
Esempio n. 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Config::get('validator.admin.role'));
     if ($validator->passes()) {
         $role = new Role();
         $role->name = Input::get('name');
         $role->deletable = 1;
         // Was the blog post created?
         if ($role->save()) {
             //Set all permission to deny
             $resources = Resource::where('in_admin_ui', '=', 1)->get();
             $data = array();
             foreach ($resources as $resource) {
                 foreach (Action::all() as $action) {
                     $data[] = array('role_id' => $role->id, 'type' => 'deny', 'action_id' => $action->id, 'resource_id' => $resource->id);
                 }
             }
             DB::table('permissions')->insert($data);
             //track user
             parent::track('create', 'Role', $role->id);
             return Redirect::to('admin/role_permission')->with('success', Lang::get('admin.role_save_success'));
         }
         // Redirect to the blog post create role
         return Redirect::to('admin/role/create')->with('error', Lang::get('admin.role_save_fail'));
     }
     // Form validation failed
     return Redirect::to('admin/role/create')->withInput()->withErrors($validator);
 }
Esempio n. 7
0
 public function run()
 {
     //DB::table('roles')->delete();
     DB::statement('ALTER TABLE permissions AUTO_INCREMENT = 1');
     $adminRole = new Role();
     $adminRole->name = 'admin';
     $adminRole->save();
     $user = User::where('username', '=', 'admin')->first();
     $user->attachRole($adminRole);
     $BrokerRole = new Role();
     $BrokerRole->name = 'broker';
     $BrokerRole->save();
     $user = User::where('username', '=', 'broker')->first();
     $user->attachRole($BrokerRole);
     $campusRole = new Role();
     $campusRole->name = 'campus';
     $campusRole->save();
     $user = User::where('username', '=', 'campus')->first();
     $user->attachRole($campusRole);
     $communityRole = new Role();
     $communityRole->name = 'community';
     $communityRole->save();
     $user = User::where('username', '=', 'community')->first();
     $user->attachRole($communityRole);
 }
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     // DB::table('departments')->truncate();
     //    $department = new Department;
     //    $department->department_desc = 'ADMIN';
     //    $department->save();
     DB::table('roles')->truncate();
     $role = new Role();
     $role->name = 'ADMINISTRATOR';
     $role->save();
     DB::table('users')->truncate();
     DB::table('assigned_roles')->truncate();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = '031988';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     // $user->confirmed = 1;
     // $user->active = 1;
     // $user->department_id = $department->id;
     $user->save();
     $user->roles()->attach($role->id);
     // id only
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Esempio n. 9
0
 public function setupDatabases()
 {
     $name = $this->call('migrate', array('--path' => 'app/database/migrations/setup/'));
     $name = $this->call('migrate');
     // create the roles
     $roles = ['Admin', 'Writer', 'Reader'];
     foreach ($roles as $r) {
         $role = Role::whereName($r)->first();
         if ($role == null) {
             $role = new Role();
             $role->name = $r;
             $role->display_name = $r;
             $role->save();
             $this->info("{$role->id} Creating Role:{$r}");
         }
     }
     foreach (User::all() as $u) {
         $this->info("{$u->id} : user: {$u->username}");
     }
     // add core assets
     $m = Asset::findFromTag('missing-user-image');
     if ($m == NULL) {
         $m = new Asset();
         $m->path = "assets/content/uploads";
         $m->saveLocalFile(public_path('assets/content/common/missing/profile-default.png'), 'profile-default.png');
         $m->tag = 'missing-user-image';
         $m->shared = 1;
         $m->type = Asset::ASSET_TYPE_IMAGE;
         $m->save();
     }
     $this->comment("****\tAll Databases for Halp have been setup :-) \t****");
     return;
 }
 /**
  * Set permission value
  *
  * @param void
  * @return null
  */
 function set_permission_value()
 {
     if ($this->active_role->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if ($this->active_role->getType() == ROLE_TYPE_PROJECT) {
         $this->httpError(HTTP_ERR_INVALID_PROPERTIES);
     }
     // if
     if ($this->request->isSubmitted() && $this->request->isAsyncCall()) {
         $permission_name = $this->request->get('permission_name');
         if ($permission_name) {
             $this->active_role->setPermissionValue($permission_name, $this->request->post('value'));
             $save = $this->active_role->save();
             if ($save && !is_error($save)) {
                 $this->httpOk();
             }
             // if
         }
         // if
         $this->httpError(HTTP_ERR_OPERATION_FAILED);
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
Esempio n. 11
0
 public function testAddingUserToRole()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $role = new Role();
     $role->name = 'myRole';
     $role->validate();
     $saved = $role->save();
     $this->assertTrue($saved);
     $benny = User::getByUsername('benny');
     //Add the role to benny
     $benny->role = $role;
     $saved = $benny->save();
     $this->assertTrue($saved);
     $roleId = $role->id;
     unset($role);
     $role = Role::getById($roleId);
     $this->assertEquals(1, $role->users->count());
     $this->assertTrue($role->users[0]->isSame($benny));
     //Now try adding billy to the role but from the other side, from the role side.
     $billy = User::getByUsername('billy');
     $role->users->add($billy);
     $saved = $role->save();
     $this->assertTrue($saved);
     $billy->forget();
     //need to forget billy otherwise it won't pick up the change. i tried unset(), test fails
     $billy = User::getByUsername('billy');
     $this->assertTrue($billy->role->id > 0);
     $this->assertTrue($billy->role->isSame($role));
 }
Esempio n. 12
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aRole !== null) {
             if ($this->aRole->isModified() || $this->aRole->isNew()) {
                 $affectedRows += $this->aRole->save($con);
             }
             $this->setRole($this->aRole);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = TeamNotePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += TeamNotePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 13
0
 /**
  * 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.");
         }
     }
 }
Esempio n. 14
0
 public function executeProcessNewOrgForm(sfWebRequest $request)
 {
     $f = $request->getParameter("organization");
     $p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
     $o = new Organization();
     $o->setName($f["name"]);
     $o->setDescription($f["description"]);
     $o->setCreatedAt(date('Y-m-d H:i:s'));
     $o->save();
     $op = new OrganizationPrincipal();
     $op->setOrganization($o);
     $op->setPrincipal($p);
     $op->save();
     $i = new Invitation();
     $i->setEmail($p->getEmail());
     $i->setOrganization($o);
     $i->setUuid('1');
     $i->setCreatedAt(date('Y-m-d H:i:s'));
     $i->setAcceptAt(date('Y-m-d H:i:s'));
     $i->setCounter(1);
     $i->setInviter($p);
     $i->setPrincipal($p);
     $i->setStatus("accepted");
     $i->save();
     $r = new Role();
     $r->setName($f["role_name"]);
     $r->setOrganization($o);
     $r->setShoworder(0);
     $r->save();
     $o->setDefaultRoleId($r->getId());
     $o->save();
     $this->redirect("show/index?id=" . $o->getId());
 }
Esempio n. 15
0
 /**
  * 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.');
         }
     }
 }
Esempio n. 16
0
 public function run()
 {
     if (file_exists(app_path() . '/config/creds.yml')) {
         $creds = yaml_parse_file(app_path() . '/config/creds.yml');
     } else {
         $creds = array('admin_email' => '*****@*****.**');
     }
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $creds['admin_email'])->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
Esempio n. 17
0
 public function run()
 {
     /**
      *  $userModel = User::find(1);
      *  $userModel->detachRoles($userModel->roles);
      */
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('roles')->truncate();
     DB::table('roles')->delete();
     DB::table('assigned_roles')->truncate();
     DB::table('assigned_roles')->delete();
     DB::table('users')->truncate();
     DB::table('users')->delete();
     User::create(array('firstname' => 'Администратор', 'email' => '*****@*****.**', 'password' => Hash::make('123456')));
     User::create(array('firstname' => 'Богдан', 'email' => '*****@*****.**', 'password' => Hash::make('123456')));
     $role = new Role();
     $role->name = 'Customer';
     $role->save();
     $role = new Role();
     $role->name = 'Admin';
     $role->save();
     $admin = User::where('firstname', '=', 'Администратор')->first();
     $admin->attachRole($role);
     $user = User::where('firstname', '=', 'Богдан')->first();
     $user->attachRole($role);
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
 public function setupFoundorAndBaseRolsPermission()
 {
     // Create Roles
     $founder = new Role();
     $founder->name = 'Founder';
     $founder->save();
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     // Create User
     $user = User::create(['github_id' => 324764, 'github_url' => 'https://github.com/summerblue', 'name' => 'summerblue']);
     // Attach Roles to user
     $user->roles()->attach($founder->id);
     // Create Permissions
     $manageTopics = new Permission();
     $manageTopics->name = 'manage_topics';
     $manageTopics->display_name = 'Manage Topics';
     $manageTopics->save();
     $manageUsers = new Permission();
     $manageUsers->name = 'manage_users';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->save();
     // Assign Permission to Role
     $founder->perms()->sync([$manageTopics->id, $manageUsers->id]);
     $admin->perms()->sync([$manageTopics->id]);
 }
 public function setupFoundorAndBaseRolsPermission()
 {
     // Create Roles
     $founder = new Role();
     $founder->name = 'Founder';
     $founder->save();
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     // Create User
     $user = User::create(['id' => 1, 'username' => 'zhanglei', 'password' => Hash::make('zhanglei'), 'email' => '*****@*****.**']);
     // Attach Roles to user
     $user->roles()->attach($founder->id);
     // Create Permissions
     $manageTopics = new Permission();
     $manageTopics->name = 'manage_topics';
     $manageTopics->display_name = 'Manage Topics';
     $manageTopics->save();
     $manageUsers = new Permission();
     $manageUsers->name = 'manage_users';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->save();
     // Assign Permission to Role
     $founder->perms()->sync([$manageTopics->id, $manageUsers->id]);
     $admin->perms()->sync([$manageTopics->id]);
 }
Esempio n. 20
0
 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $adminEmail)->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
Esempio n. 21
0
 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 = '******';
         $adminUser->email = '*****@*****.**';
         $adminUser->password = '******';
         $adminUser->password_confirmation = 'admin';
         $adminUser->confirmation_code = md5(uniqid(mt_rand(), true));
         if ($adminUser->save()) {
             $adminUser->attachRole($admin);
             echo "Admin User Created";
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $role = new Role();
     $role->name = Input::get('name');
     $role->save();
     return Redirect::route('roles.index');
 }
 public function run()
 {
     DB::table('roles')->truncate();
     $faker = Faker\Factory::create();
     $adminRole = new Role();
     $adminRole->name = 'admin';
     $adminRole->save();
     $moderatorRole = new Role();
     $moderatorRole->name = 'moderator';
     $moderatorRole->save();
     $authorRole = new Role();
     $authorRole->name = 'author';
     $authorRole->save();
     $user = User::where('username', '=', 'ad_user')->first();
     $user->attachRole($adminRole);
     //        $user = User::where('username','=','ad_user1')->first();
     //        $user->attachRole( $adminRole );
     $m = User::where('username', '=', 'moderator')->first();
     $m->attachRole($moderatorRole);
     //        $m = User::where('username','=','mo_user1')->first();
     //        $m->attachRole($moderatorRole);
     $a = User::where('username', '=', 'author')->first();
     $a->attachRole($authorRole);
     //        $a  = User::where('username','=','au_user1')->first();
     //        $a->attachRole($authorRole);
 }
 public function run()
 {
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = '@Password1';
     $user->confirmed = 1;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->save();
     $profile = new Profile();
     $profile->user_id = $user->id;
     $profile->firstname = 'David';
     $profile->lastname = 'Hernandez';
     $profile->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile->avatar = '/img/coach-avatar.jpg';
     $profile->save();
     if (!$user->id) {
         Log::info('Unable to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
     }
     $user1 = new User();
     $user1->username = '******';
     $user1->email = '*****@*****.**';
     $user1->password = '******';
     $user1->password_confirmation = '@Password1';
     $user1->confirmed = 1;
     $user1->confirmation_code = md5(uniqid(mt_rand(), true));
     $user1->save();
     $profile1 = new Profile();
     $profile1->user_id = $user1->id;
     $profile1->firstname = 'David';
     $profile1->lastname = 'Hernandez';
     $profile1->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile1->avatar = '/img/coach-avatar.jpg';
     $profile1->save();
     if (!$user1->id) {
         Log::info('Unable to create user ' . $user1->username, (array) $user1->errors());
     } else {
         Log::info('Created user "' . $user1->username . '" <' . $user1->email . '>');
     }
     $admin = new Role();
     $admin->name = 'administrator';
     $admin->save();
     $club = new Role();
     $club->name = 'club owner';
     $club->save();
     $club2 = new Role();
     $club2->name = 'club administrator';
     $club2->save();
     $default = new Role();
     $default->name = 'default';
     $default->save();
     $user->attachRole($club);
     $user1->attachRole($default);
 }
Esempio n. 25
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $inputs = Input::except('csrf_token');
         $this->role->name = $inputs['name'];
         $this->role->save();
         $this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
         if ($this->role->id) {
             return Redirect::to('admin/roles/' . $this->role->id . '/edit')->with('success', Lang::get('admin/roles/messages.create.success'));
         }
         return Redirect::to('admin/roles/create')->with('error', Lang::get('admin/roles/messages.create.error'));
         return Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('admin/roles/messages.' . $error));
     }
     return Redirect::to('admin/roles/create')->withInput()->withErrors($validator);
 }
Esempio n. 26
0
 function createRole($id, $title, $label = null)
 {
     $role = new Role();
     $role->id = $id;
     $role->title = $title;
     $role->label = $label ?: $title;
     $role->save();
 }
Esempio n. 27
0
 /**
  * Stores new account
  *
  * @return  Illuminate\Http\Response
  */
 public function store()
 {
     $perms = Input::get('permission');
     $role = new Role();
     $role->name = Input::get('name');
     $role->save();
     $role->perms()->sync($perms);
     return Redirect::route('roles.index');
 }
Esempio n. 28
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Administrator';
     $admin->save();
     $user = User::where('email', '=', '*****@*****.**')->first();
     $user->attachRole($admin);
 }
Esempio n. 29
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function save($data)
 {
     $this->validate($data);
     $model = new Role();
     $model->fill($data);
     if ($model->save()) {
         return 'Role was saved.';
     }
     return 'Role was not saved.';
 }
Esempio n. 30
0
 /**
  * Store a newly created resource in storage.
  * POST /roles
  *
  * @return Response
  */
 public function store()
 {
     if (Input::has('role-name')) {
         $role = new Role();
         $role->name = Input::get('role-name');
         $role->save();
         return Redirect::back()->with(['notice' => 'new role created']);
     }
     return Redirect::back()->with(['notice' => 'Missing a role name']);
 }