public function destroy($id) { $course = Course::find($id); $course->delete(); $status = 'Course ' . $course->name . ' been successful deleted'; return Response::json($status); }
public function deleteCourse($id) { $course = Course::findOrFail($id); $course->delete(); if (null == Course::find($id)) { //Нет упоминаний о курсе и удаление прошло $this->courseId = null; $result = true; } else { $this->courseId = $course->id; $result = false; } return $result; }
/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit($id) { $url = URL::route('course.update', ['id' => $id]); $courseName = Course::find($id)->name; return View::make('pages.course.edit', compact('courseName', 'url')); }
public static function deleteCourse($id) { try { $course = Course::findOrFail($id); $course->delete(); if (Course::find($id) == null) { //Курса нет более $message = 'Course ' . $course->name . ' been successful deleted'; $status = 'success'; } else { $message = 'Course ' . $course->name . ' not been deleted'; $status = 'fail'; } } catch (ModelNotFoundException $e) { //Мимо.Нет такой страницы $message = 'Course not found'; $status = 'fail'; } return array('message' => $message, 'status' => $status); }