示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Season::create(['name' => date('Y') . '-' . (date('y') + 1)]);
     Program::create(['name' => 'Beginner Bible Bowl', 'abbreviation' => 'Beginner', 'slug' => 'beginner', 'registration_fee' => '25.00', 'min_grade' => 2, 'max_grade' => 5]);
     Program::create(['name' => 'Teen Bible Bowl', 'abbreviation' => 'Teen', 'slug' => 'teen', 'registration_fee' => '35.00', 'min_grade' => 6, 'max_grade' => 12]);
     GroupType::create(['name' => 'Christian School']);
     GroupType::create(['name' => 'Homeschool']);
     GroupType::create(['name' => 'Church']);
     GroupType::create(['name' => 'Other']);
     ParticipantType::create(['name' => 'Team']);
     ParticipantType::create(['name' => 'Player']);
     ParticipantType::create(['name' => 'Quizmaster']);
     ParticipantType::create(['name' => 'Spectator - Adult', 'description' => 'Single adult']);
     ParticipantType::create(['name' => 'Spectator - Family', 'description' => 'Up to 2 adults and children who are not players']);
     EventType::create(['participant_type_id' => ParticipantType::TEAM, 'name' => 'Round Robin']);
     EventType::create(['participant_type_id' => ParticipantType::PLAYER, 'name' => 'Quote Bee']);
     EventType::create(['participant_type_id' => ParticipantType::TEAM, 'name' => 'Double Elimination']);
     EventType::create(['participant_type_id' => ParticipantType::PLAYER, 'name' => 'BuzzOff']);
     EventType::create(['participant_type_id' => ParticipantType::PLAYER, 'name' => 'King of the Hill']);
     Bouncer::allow(Role::ADMIN)->to([Ability::VIEW_REPORTS, Ability::MANAGE_ROLES, Ability::MANAGE_USERS, Ability::MANAGE_GROUPS, Ability::MANAGE_PLAYERS, Ability::CREATE_TOURNAMENTS, Ability::SWITCH_ACCOUNTS, Ability::MANAGE_SETTINGS]);
     Bouncer::allow(Role::BOARD_MEMBER)->to(Ability::VIEW_REPORTS);
     Bouncer::allow(Role::HEAD_COACH)->to([Ability::MANAGE_ROSTER, Ability::MANAGE_TEAMS]);
     Role::create(['name' => Role::COACH, 'mailchimp_interest_id' => '29a52dd6fc']);
     Role::create(['name' => Role::LEAGUE_COORDINATOR, 'mailchimp_interest_id' => '9b90dc8bdd']);
     Role::create(['name' => Role::QUIZMASTER, 'mailchimp_interest_id' => 'fe3a183033']);
     Bouncer::allow(Role::QUIZMASTER);
     Bouncer::allow(Role::GUARDIAN)->to(Ability::REGISTER_PLAYERS);
     Role::where('name', Role::HEAD_COACH)->update(['mailchimp_interest_id' => 'be4c459134']);
     Role::where('name', Role::GUARDIAN)->update(['mailchimp_interest_id' => '0f83e0f312']);
     $howDidYouHearAbout = RegistrationSurveyQuestion::create(['question' => 'How did you hear about Bible Bowl?', 'order' => 1]);
     $howDidYouHearAbout->answers()->saveMany([app(RegistrationSurveyAnswer::class, [['answer' => 'Friend', 'order' => '1']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Church brochure/bulletin', 'order' => '2']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Homeschool convention', 'order' => '3']]), app(RegistrationSurveyAnswer::class, [['answer' => 'TV', 'order' => '4']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Web Advertisement', 'order' => '5']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Internet', 'order' => '6']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Other', 'order' => '7']])]);
     $mostInfluential = RegistrationSurveyQuestion::create(['question' => 'Which of the following were most influential in your decision to join Bible Bowl?', 'order' => 2]);
     $mostInfluential->answers()->saveMany([app(RegistrationSurveyAnswer::class, [['answer' => "Friend's recommendation", 'order' => '1']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Attending a practice/demo/meeting', 'order' => '2']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Learning about it on the web site', 'order' => '3']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Homeschool curriculum potential', 'order' => '4']]), app(RegistrationSurveyAnswer::class, [['answer' => 'Other', 'order' => '5']])]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Bouncer::allow('role-user-users')->to(['user-list', 'user-view']);
     Bouncer::allow('role-user-manage')->to(['user-list', 'user-view', 'user-edit', 'user-create']);
     Bouncer::allow('role-user-admin')->to(['user-list', 'user-view', 'user-edit', 'user-create', 'user-remove', 'user-permissions']);
     $userAdmin = App\User::find(1);
     $userAdmin->assign('role-user-admin');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Crea en la db los roles y permisos por defecto
     Bouncer::allow('admin')->to('create_user');
     Bouncer::allow('admin')->to('edit_user', User::class);
     Bouncer::allow('admin')->to('delete_user', User::class);
     Bouncer::allow('admin')->to('view_users');
     Bouncer::allow('admin')->to('delete_logs');
     Bouncer::allow('admin')->to('view_logs');
     //asignar el rol al usuario administrador
     $user = DB::table('users')->where('email', '*****@*****.**')->value('id');
     Bouncer::assign('admin')->to($user);
     //Inserta el rol user
     DB::table('roles')->insert(['name' => 'user', 'created_at' => Carbon::now()]);
     //Create 50 users
     factory(App\User::class, 50)->create()->each(function ($u) {
         $u->assign('user');
     });
 }
示例#4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach ($this->employeeAbilities() as $doThis) {
         \Bouncer::allow('employee')->to($doThis);
     }
     foreach ($this->OwnerAbilities() as $doThis) {
         \Bouncer::allow('owner')->to($doThis);
     }
     foreach ($this->adminAbilities() as $doThis) {
         \Bouncer::allow('admin')->to($doThis);
     }
     $owners = User::whereTitle('owner')->get();
     foreach ($owners as $owner) {
         $owner->assign('owner');
     }
     User::all()->each(function ($employee) {
         $employee->assign('employee');
     });
 }
 public function create(Request $request)
 {
     if (!$request->ajax()) {
         return redirect('/login');
     }
     $createUserRequest = new CreateUserRequest();
     $validator = Validator::make($request->all(), $createUserRequest->rules(), $createUserRequest->messages());
     // Validate Form
     if ($validator->fails()) {
         return response()->json(['success' => false, 'errors' => $validator->errors()->toArray()], 400);
     }
     // Check Captcha still Valid or Used!
     if ($this->captchaCheck() == false) {
         $errors = ['captchaError' => trans('auth.captchaError')];
         return response()->json(['success' => false, 'errors' => $errors], 400);
     }
     // Check Sponsor Cookie , Provide One if None
     if (\Cookie::get('sponsor') == false) {
         try {
             $link = Link::with('user', 'user.profile')->where('link', $request->sponsor_link)->first();
             $cookie = $link->toArray();
             $errors = ['CookieError' => trans('auth.cookieError'), 'cookieNew' => trans('auth.cookieNew'), 'resubmitForm' => trans('auth.resubmitForm')];
             return response()->json(['success' => false, 'errors' => $errors], 400)->withCookie(\Cookie::forever('sponsor', $cookie));
         } catch (\Exception $e) {
             $errors = ['Warning' => 'Warning :Forbiden Link Forgery!'];
             return response()->json(['success' => false, 'errors' => $errors], 400);
         }
     }
     // This Will Prevent Unnecessary Creation of Account if Something Failed!
     DB::beginTransaction();
     $user = User::create($request->all());
     $profile = $user->profile()->create($request->all());
     $link = new Link();
     $link->link = Input::get('username');
     $user->links()->save($link);
     // IF Error Occured Throw an Exception then Rollback!
     $role = $user->assign('customer');
     $ability1 = \Bouncer::allow($user)->to('add-order', Order::class);
     $ability2 = \Bouncer::allow($user)->to('edit-order', Order::class);
     $ability3 = \Bouncer::allow($user)->to('delete-order', Order::class);
     $ability4 = \Bouncer::allow($user)->to('view-itemOrder', ItemOrder::class);
     try {
         if (!$user && !$profile && !$link && !$role && $ability1 && $ability2 && $ability3 && $ability4) {
             throw new \Exception('Account Creation Failed ,Account is Rollback');
         }
     } catch (\Exception $e) {
         DB::rollback();
         $errors = ['ExceptionError' => $e->getMessage()];
         return response()->json(['success' => false, 'errors' => $errors], 400);
         // Failed Creation
     }
     // Account Successfully Created
     DB::commit();
     // Send Email To The New User
     $this->mail->registered($user);
     $this->mail->sendToSponsor($user);
     $cookie = \Cookie::forget('sponsor');
     // Return With a Response to Delete Cookie
     Auth::LoginUsingId($user->id);
     // return redirect()->route('profile');
     return response()->json(['success' => true, 'url' => 'shipping-address'], 201)->withCookie($cookie);
 }