示例#1
0
 public function team($id)
 {
     $faker = Faker::create();
     for ($i = 1; $i <= $faker->numberBetween(24, 30); $i++) {
         Team::create(['institution_id' => $faker->numberBetween('1', count(Institution::get())), 'name' => 'Team ' . $i, 'name_altered' => 'Team ' . $i, 'robot_name' => 'Robot ' . $i, 'gender' => $faker->randomElement(['MAS', 'FEM', 'MIX']), 'challenge_id' => $id, 'degree_id' => $faker->numberBetween('1', count(Degree::get()))]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CreateTeamRequest $request)
 {
     // The request params are already been validated
     // by CreateTeamRequest
     $team = Team::create($request->all());
     return $team;
 }
示例#3
0
 /**
  * [run description]
  * @return [type] [description]
  */
 public function run()
 {
     DB::table('teams')->delete();
     $race = Db::table('races')->select('id')->first();
     Team::create(array('name' => 'Schnell', 'race_id' => $race->id));
     Team::create(array('name' => 'Ichi Ban', 'race_id' => $race->id));
     Team::create(array('name' => 'Team Pizza', 'race_id' => $race->id));
     Team::create(array('name' => 'Mostly New Guys', 'race_id' => $race->id));
     Team::create(array('name' => 'Team Mongolia', 'race_id' => $race->id));
 }
 /**
  * Store team action.
  *
  * @param  Request  $request
  * @return Response
  */
 public function storeTeam(Request $request)
 {
     $this->validate($request, $this->rules(), $this->messages());
     // Get players to associate with the team
     $players = $request->input('players', []);
     $team = Team::create($request->all());
     $team->players()->attach($players);
     $request->session()->flash('message', sprintf('Team %s added!', $team->name));
     return redirect()->route('team.list');
 }
示例#5
0
 /**
  * Fills teams table
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $t = Team::create(['name' => $faker->name(), 'abbreviation' => $faker->realText(11), 'description' => $faker->realText(150)]);
         $t->captain()->associate(User::first());
         $t->members()->attach(User::first());
         //set captain of all teams to first user
         $t->save();
     }
 }
示例#6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // This validates the information. All I'm doing right now is requiring the first and last name.
     // You can add more if you'd like to. If it fails it will thrown an exception and send back
     // to the that was sent from
     // check out http://laravel.com/docs/5.1/validation#available-validation-rules
     $this->validate($request, ['name' => 'required']);
     // Make sure that the classes are imported on top of the file with the use in front.
     // Player is the class and is used up top by doing. use App\Player;
     Team::create($request->all());
     // redirect helper function to send them after storing in database
     return redirect('teams');
 }
示例#7
0
 public function create(Request $request)
 {
     $r = Team::create(array('title' => $request->get('title'), 'intro' => $request->get('intro'), 'header' => $request->get('header'), 'allow_join' => $request->get('allow_join'), 'is_open' => $request->get('is_open'), 'tags' => $request->get('tags'), 'user_id' => \Auth::user()->id));
     if ($r) {
         $r2 = TeamMember::create(array('team_id' => $r->id, 'user_id' => \Auth::user()->id, 'role' => 0));
         $r3 = TeamTrace::create(array('team_id' => $r->id, 'user_id' => \Auth::user()->id, 'act' => '创建了', 'target' => $r->title, 'type' => 0));
         if ($r2 && $r3) {
             $this->succeed(true);
         } else {
             $this->fail(true);
         }
     } else {
         $this->fail(true);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     // upload image - avatar
     if (\Input::hasFile('avatar')) {
         $file = \Input::file('avatar');
         $imagename = 'cycling_passion_team_member' . time() . '_' . $file->getClientOriginalName();
         $path = public_path('uploads/small/' . $imagename);
         $image = \Image::make($file->getRealPath())->resize(200, 100)->save($path);
         // fit invece di resize x ritagliare
         $input['avatar'] = $imagename;
     }
     Team::create($input);
     //return redirect()->back();
     return redirect('/admin/teams')->with('message', 'Team Member created');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['photo' => 'required|image|max:2000', 'name' => 'required|min:5', 'position' => 'required', 'description' => 'required|min:30', 'description2' => 'required_with:description3']);
     $member = [];
     $photo = Input::file('photo');
     if ($photo->isValid()) {
         $ext = $photo->getClientOriginalExtension();
         $destination = 'images';
         $name = explode(' ', $request->input('name'));
         $name = strtolower($name[0]);
         $filename = $name . '.' . $ext;
         $member['photo'] = $filename;
         $photo->move($destination, $filename);
     }
     $member['name'] = strtolower($request->input('name'));
     $member['position'] = strtolower($request->input('position'));
     $member['description'] = $request->input('description');
     $member['description2'] = trim($request->input('description2')) != "" ? trim($request->input('description2')) : null;
     $member['description3'] = trim($request->input('description3')) != "" ? trim($request->input('description3')) : null;
     Team::create($member);
     return redirect('admin/team');
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     Team::create(['namateam' => $data['namateam'], 'kategori' => $data['kategori'], 'instansi' => $data['instansi'], 'alamatinstansi' => $data['alamatinstansi']]);
     $team = Team::where('namateam', $data['namateam'])->first();
     if ($data['kategori'] == 0) {
         $max = 2;
         $level = 0;
     } else {
         $max = 3;
         $level = 0;
     }
     if (isset($data['anggota'])) {
         $max = count($data['anggota']) > $max ? $max : count($data['anggota']);
         $anggota = $data['anggota'];
         for ($i = 0; $i < $max; $i++) {
             User::create(['nama' => $anggota[$i]['nama'], 'email' => $anggota[$i]['email'], 'notelp' => $anggota[$i]['notelp'], 'idteam' => $team['id']]);
         }
     }
     $user = User::create(['nama' => $data['namaketua'], 'email' => $data['emailketua'], 'password' => bcrypt($data['password']), 'notelp' => $data['notelp'], 'code' => str_random(30), 'level' => $level, 'idteam' => $team['id']]);
     $user['kategori'] = $data['kategori'];
     return $user;
 }
 public function addTeam(Request $request)
 {
     $input = $request->all();
     Team::create($input);
     return redirect()->back();
 }
示例#12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  App\Http\Requests\CreateTeamRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateTeamRequest $request)
 {
     $team_name = $request->input('team_name');
     Team::create([$team_name]);
     return redirect(action('UserController@index'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('teams')->delete();
     Team::create(['name' => 'Brave Heart', 'country' => 'China', 'region' => 'Asia', 'active' => true, 'created_on' => '2014-12-15', 'overview' => 'is a Chinese e-Sports organisation currently fielding teams in Starcraft 2, Heroes of the Storm, and Dota 2.']);
     Team::create(['name' => 'CDEC Gaming', 'country' => 'China', 'region' => 'Asia', 'active' => true, 'created_on' => '2014', 'overview' => 'In October 2014, the former LGD Gaming "youth" squad LGD.CDEC left the LGD Gaming organization to establish an independent club called CDEC Gaming.']);
 }
示例#14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Team::create(['name' => 'Test team']);
     Team::create(['name' => 'NODE5 staff']);
 }
示例#15
0
 /**
  * Creates a new team and returns its id.
  *
  * @param string
  * @return int
  */
 private function create_new_team($team_name)
 {
     $team = Team::create(compact('team_name'));
     return $team->team_id;
 }
示例#16
0
 public function checkThree(Request $request)
 {
     $data = $request->all();
     $dataOne = Tool::removeSpace($data['datosOne']);
     $dataTwo = Tool::removeSpace($data['datosTwo']);
     $dataThree = Tool::removeSpace($data['datosThree']);
     $validatorOne = Validator::make($dataOne, ["Institución" => "required", "Nombre_del_equipo" => "required|name_team", "Nombre_del_robot" => "required|alpha_space", "Tipo" => "required", "Reto" => "required", "Grado" => "required"]);
     $validatorTwo = Validator::make($dataTwo, ["Nombre" => "required|alpha_space", "Apellido_Paterno" => "required|alpha", "Apellido_Materno" => "required|alpha", "Correo" => "required|email|unique:rb_users,email", "Correo_confirmación" => "required|email|same:Correo", "Correo_alterno" => "required|email", "Nombre_Coach_auxiliar" => "required|alpha_space", "Apellido_Paterno_Coach_auxiliar" => "required|alpha", "Apellido_Materno_Coach_auxiliar" => "required|alpha", "Nombre_coordinador" => "required|alpha_space", "Apellido_paterno_coordinador" => "required|alpha", "Apellido_materno_coordinador" => "required|alpha"]);
     $validatorThree = Validator::make($dataThree, ["Nombre_capitan" => "required|alpha_space", "Apellido_paterno_capitan" => "required|alpha", "Apellido_materno_capitan" => "required|alpha", "Nombre_2_integrante" => "required|alpha_space", "Apellido_paterno_2_integrante" => "required|alpha", "Apellido_materno_2_integrante" => "required|alpha", "Nombre_3_integrante" => "required|alpha_space", "Apellido_paterno_3_integrante" => "required|alpha", "Apellido_materno_3_integrante" => "required|alpha", "Nombre_4_integrante" => "required|alpha_space", "Apellido_paterno_4_integrante" => "required|alpha", "Apellido_materno_4_integrante" => "required|alpha"]);
     $toArrayOne = $validatorOne->errors()->toArray();
     $toArrayTwo = $validatorTwo->errors()->toArray();
     $toArrayThree = $validatorThree->errors()->toArray();
     if ($validatorOne->fails() || $validatorTwo->fails() || $validatorThree->fails()) {
         return response()->json(['success' => false, 'errors' => ['uno' => $toArrayOne, 'dos' => $toArrayTwo, 'tres' => $toArrayThree]]);
     }
     $pas = Tool::generateKey(['MI' => true, 'NU' => true, 'CA' => true, 'MA' => true, 'LEN' => 10]);
     DB::beginTransaction();
     try {
         Mail::send('mails.mail', ['user' => 'Ricardio'], function ($msj) {
             $msj->to('*****@*****.**')->subject('Este es un correo de prueba de la liga de robotica');
         });
         $team = Team::create(['institution_id' => $dataOne['Institución'], 'name' => $dataOne['Nombre_del_equipo'], 'name_altered' => Tool::getName($dataOne['Nombre_del_equipo']), 'robot_name' => $dataOne['Nombre_del_robot'], 'gender' => $dataOne['Tipo'], 'challenge_id' => $dataOne['Reto'], 'degree_id' => $dataOne['Grado']]);
         $team_id = $team->id;
         $userOne = User::create(['name' => $dataTwo['Nombre'], 'last_name' => $dataTwo['Apellido_Paterno'], 'last_name_m' => $dataTwo['Apellido_Materno'], 'email' => $dataTwo['Correo'], 'email_alter' => $dataTwo['Correo_alterno'], 'password' => bcrypt($pas), 'password_two' => base64_encode($pas), 'role_id' => 2]);
         $coach_id = $userOne->id;
         $userTwo = User::create(['name' => $dataTwo['Nombre_Coach_auxiliar'], 'last_name' => $dataTwo['Apellido_Paterno_Coach_auxiliar'], 'last_name_m' => $dataTwo['Apellido_Materno_Coach_auxiliar'], 'role_id' => 3]);
         $coach_aux_id = $userTwo->id;
         if ($dataTwo['Coordinado'] != 'S') {
             $userThree = User::create(['name' => $dataTwo['Nombre_coordinador'], 'last_name' => $dataTwo['Apellido_paterno_coordinador'], 'last_name_m' => $dataTwo['Apellido_materno_coordinador'], 'role_id' => 4]);
             $coordinador_id = $userThree->id;
         } else {
             $coordinador_id = $coach_aux_id;
         }
         $cap = User::create(['name' => $dataThree['Nombre_capitan'], 'last_name' => $dataThree['Apellido_paterno_capitan'], 'last_name_m' => $dataThree['Apellido_materno_capitan'], 'role_id' => 5]);
         $cap_id = $cap->id;
         $userdos = User::create(['name' => $dataThree['Nombre_2_integrante'], 'last_name' => $dataThree['Apellido_paterno_2_integrante'], 'last_name_m' => $dataThree['Apellido_materno_2_integrante'], 'role_id' => 6]);
         $userdos_id = $userdos->id;
         $userthre = User::create(['name' => $dataThree['Nombre_3_integrante'], 'last_name' => $dataThree['Apellido_paterno_3_integrante'], 'last_name_m' => $dataThree['Apellido_materno_3_integrante'], 'role_id' => 7]);
         $userthre_id = $userthre->id;
         $userfour = User::create(['name' => $dataThree['Nombre_3_integrante'], 'last_name' => $dataThree['Apellido_paterno_3_integrante'], 'last_name_m' => $dataThree['Apellido_materno_3_integrante'], 'role_id' => 8]);
         $userfour_id = $userfour->id;
         RelationTeUs::create(['team_id' => $team_id, 'user_coach_id' => $coach_id, 'user_coach_aux_id' => $coach_aux_id, 'user_coordinador_id' => $coordinador_id, 'user_cap_id' => $cap_id, 'user_int2_id' => $userdos_id, 'user_int3_id' => $userthre_id, 'user_int4_id' => $userfour_id]);
     } catch (\Exception $e) {
         DB::rollback();
     }
     DB::commit();
     return response()->json(['success' => true]);
 }
示例#17
0
 function initTeams($numTeams)
 {
     for ($i = 1; $i <= $numTeams; $i++) {
         Team::create();
     }
 }