/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $promos = Promo::all(); foreach ($promos as $promo) { $promo->nbStudent = count(Student::where('promo', $promo->id)->get()); } return view('admin.promo.list', compact('promos')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $student = Student::findOrFail($id); $student->delete(); return redirect('admin/Student'); }