/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $pupil = Pupil::findOrFail($id); $schools = School::orderBy('name')->get(); $schoolmapping = []; foreach ($schools as $school) { $schoolmapping[$school->id] = $school->name . ' (' . $school->town . ')'; } $pupil->grade = $pupil->getGrade(); return view('pupil.edit', ['pupil' => $pupil, 'schoolmapping' => $schoolmapping]); }
public function index() { return view('school.index', ['schools' => School::orderBy('name')->get()]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $schools = School::orderBy('name')->get(); return view('school.index', ['schools' => $schools]); }