public function pRegistrarEventoPartido() { $data = Input::only(['evento_nombre', 'evento_genero', 'evento_descripcion', 'evento_youtube', 'CP_lugar', 'evento_fechaInicio', 'evento_fechaFin', 'evento_user', 'evento_principal', 'evento_password', 'slug']); $rules = ['evento_nombre' => 'required', 'evento_genero' => 'required', 'evento_descripcion' => 'required', 'evento_youtube', 'CP_lugar' => 'required', 'evento_fechaInicio' => 'required', 'evento_fechaFin' => 'required', 'evento_user' => 'required', 'evento_password' => 'required', 'evento_principal' => 'required']; $validation = \Validator::make($data, $rules); array_set($data, 'slug', \Str::slug($data['evento_nombre'])); if ($validation->passes()) { if ($data['evento_principal'] == '1') { $auxPrincipal = Eventos::where('evento_principal', '=', 1)->get(); foreach ($auxPrincipal as $auxPrincipals) { $auxPrincipals->evento_principal = 0; $auxPrincipals->save(); } } $destinationPath = ''; $filename = ''; $destinationPathwall = ''; $filenamewall = ''; if (Input::hasFile('image')) { $file = Input::file('image'); $destinationPath = public_path() . '/img/'; $filename = str_random(6) . '_' . $file->getClientOriginalName(); $uploadSuccess = $file->move($destinationPath, $filename); } if (Input::hasFile('imageBackground')) { $file = Input::file('imageBackground'); $destinationPathwall = public_path() . '/img/'; $filenamewall = str_random(6) . '_' . $file->getClientOriginalName(); $uploadSuccess = $file->move($destinationPathwall, $filenamewall); } $eventoPelicula = new Eventos($data); $eventoPelicula->evento_tipo = 'partido'; $eventoPelicula->evento_img = $filename; $eventoPelicula->evento_background = $filenamewall; $eventoPelicula->evento_estado = 1; $eventoPelicula->evento_password = \Hash::make($data['evento_password']); $eventoPelicula->save(); return Redirect::route('vCrearHorarioPartido', [$eventoPelicula->slug, $eventoPelicula->id]); } return Redirect::back()->withInput()->withErrors($validation->messages()); }