public function destroy($id) { $room = Room::with('schedules')->find($id); if ($room->schedules->count() > 0) { Session::flash('message', 'Tidak dapat menghapus ruangan! Ruangan ini digunakan dalam jadwal belajar'); } else { Room::destroy($id); Session::flash('message', 'Sukses menghapus ruangan!'); } }
/** * Remove the specified room from storage. * * @param int $id * @return Response */ public function getDestroy($id) { Room::destroy($id); return Redirect::action('RoomsController@getIndex'); }