/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $faker = Faker\Factory::create(); for ($i = 0; $i < 20; $i++) { $tutors = Tutor::create(array('name' => $faker->unique()->word, 'speciality' => $faker->url, 'description' => $faker->paragraph($nbSentences = 5))); } }
/** * Update the specified resource in storage. * * @param Inscription $inscription * @return Response */ public function update(Inscription $inscription, Request $request) { $this->authorize('edit', $inscription); //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input. //$inscription = Inscription::findOrFail($id); if (!isset($request['step']) || $request['step'] < 1 && $request['step'] > 3) { return redirect('inscription.create'); } //actualizar estudiante if ($request['step'] == 1) { $inscription->student->update($request->all()); //actualizar grupo if ($inscription->group_id != $request['group_id']) { //buscar grupo anterior $inscription->group->students()->detach($inscription->student); //agregamos al nuevo $inscription->group_id = $request['group_id']; $group = Group::find($request['group_id']); $group->students()->attach($inscription->student); } $inscription->update($request->all()); //mostrar paso 2 return view('inscription.step2', compact('inscription')); } elseif ($request['step'] == 2) { if ($request['tutor_id'] != 0 && $inscription->tutor_id != $request['tutor_id']) { $inscription->student->tutor_id = $request['tutor_id']; $inscription->student->save(); } if ($inscription->student->tutor) { $inscription->student->tutor->update($request->all()); } else { $inscription->student->tutor_id = Tutor::create($request->all())->id; $inscription->student->save(); } //mostrar paso 3 ... return view('inscription.step3', compact('inscription')); } elseif ($request['step'] == 3) { if ($inscription->student->document) { $request['student_id'] = $inscription->student_id; $inscription->student->document->update($request->all()); } else { $request['student_id'] = $inscription->student_id; Document::create($request->all()); return redirect()->route('inscription.show', [$inscription]); } } return redirect('inscription'); }