public function submit_create_oferta_expediente() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); // Verifico si el usuario es un Webmaster if ($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4) { // Validate the info, create rules for the inputs $attributes = array('idproveedor' => 'Proveedor', 'precio' => 'Precio', 'caracteristicas' => 'Características Principales', 'archivo' => 'Archivo adjunto'); $messages = array(); $rules = array('idproveedor' => 'required', 'precio' => 'required|numeric', 'caracteristicas' => 'required|max:255', 'archivo' => 'required|max:15360'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules, $messages, $attributes); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('oferta_expediente/create_oferta_expediente/' . Input::get('idexpediente_tecnico'))->withErrors($validator)->withInput(Input::all()); } else { if (Input::hasFile('archivo')) { $archivo = Input::file('archivo'); $rutaDestino = 'uploads/documentos/adquisicion/oferta/'; $nombre_archivo = $archivo->getClientOriginalName(); $nombre_archivo_encriptado = Str::random(27) . '.' . pathinfo($nombre_archivo, PATHINFO_EXTENSION); $uploadSuccess = $archivo->move($rutaDestino, $nombre_archivo_encriptado); } $oferta_expediente = new OfertaExpediente(); $oferta_expediente->correlativo_por_expediente = Input::get('correlativo'); $oferta_expediente->idexpediente_tecnico = Input::get('idexpediente_tecnico'); $oferta_expediente->idproveedor = Input::get('idproveedor'); $oferta_expediente->precio = Input::get('precio'); $oferta_expediente->caracteristicas = Input::get('caracteristicas'); $oferta_expediente->url = $rutaDestino; $oferta_expediente->nombre_archivo = $nombre_archivo; $oferta_expediente->nombre_archivo_encriptado = $nombre_archivo_encriptado; $oferta_expediente->save(); Session::flash('message', 'Se registró correctamente la Oferta.'); return Redirect::to('oferta_expediente/list_oferta_expedientes'); } } else { return View::make('error/error', $data); } } else { return View::make('error/error', $data); } }