/** * Run the database seeds. * * @return void */ public function run() { Postulacion::create(['postulante_id' => 1, 'cargo_id' => 15, 'fecha' => '2015-11-10']); Postulacion::create(['postulante_id' => 2, 'cargo_id' => 14, 'fecha' => '2015-12-3']); Postulacion::create(['postulante_id' => 3, 'cargo_id' => 13, 'fecha' => '2015-6-1']); Postulacion::create(['postulante_id' => 4, 'cargo_id' => 12, 'fecha' => '2015-5-8']); Postulacion::create(['postulante_id' => 5, 'cargo_id' => 11, 'fecha' => '2015-5-10']); Postulacion::create(['postulante_id' => 6, 'cargo_id' => 10, 'fecha' => '2015-2-10']); Postulacion::create(['postulante_id' => 7, 'cargo_id' => 9, 'fecha' => '2015-5-6']); Postulacion::create(['postulante_id' => 8, 'cargo_id' => 8, 'fecha' => '2015-11-10']); Postulacion::create(['postulante_id' => 9, 'cargo_id' => 7, 'fecha' => '2015-1-20']); Postulacion::create(['postulante_id' => 10, 'cargo_id' => 6, 'fecha' => '2015-6-8']); Postulacion::create(['postulante_id' => 11, 'cargo_id' => 5, 'fecha' => '2015-1-1']); Postulacion::create(['postulante_id' => 12, 'cargo_id' => 4, 'fecha' => '2015-1-1']); Postulacion::create(['postulante_id' => 13, 'cargo_id' => 3, 'fecha' => '2015-1-1']); Postulacion::create(['postulante_id' => 14, 'cargo_id' => 2, 'fecha' => '2015-1-1']); Postulacion::create(['postulante_id' => 15, 'cargo_id' => 1, 'fecha' => '2015-1-1']); }
public function postSeleccionRegistrarPostulante($id, Request $request) { $validator = Validator::make($request->all(), ['nombres' => 'required|min:3|max:50', 'dni' => 'required | max:8', 'email' => 'required|min:3|max:50', 'telefono' => 'required|max:9', 'direccion' => 'required|min:3|max:50']); if ($validator->fails()) { $data['errors'] = $validator->errors(); return redirect('personal/seleccion/postulante')->withInput($request->all())->with($data); } if ($request->hasFile('cv')) { $postulante = Postulante::create(['full_name' => $request->get('nombres'), 'dni' => $request->get('dni'), 'email' => $request->get('email'), 'phone' => $request->get('telefono'), 'address' => $request->get('direccion')]); $dni = $request->get('dni'); $file = $request->file('cv'); // Ruta donde queremos guardar las imágenes para los proveedores $path = public_path() . '/curriculums'; // Guardar $sinEspacios = str_replace(' ', '', $postulante->dni . "." . $file->getClientOriginalExtension()); $simpleName = strtolower($sinEspacios); $fileName = $simpleName; $file->move($path, $fileName); $postulante->cVitae = $simpleName; $postulante->save(); $fechaActual = Carbon::now()->toDateString(); $postulacion = Postulacion::create(['postulante_id' => $postulante->id, 'cargo_id' => $id, 'fecha' => $fechaActual]); $postulacion->save(); return redirect('personal/personal'); } else { return redirect('personal/seleccion/postulante/' . $id); } }