public function destroy($id) { $school = School::with('educations')->find($id); if ($school->educations->count() > 0) { Session::flash('message', 'Tidak dapat menghapus sekolah! Sekolah ini merupakan sekolah asal salah satu siswa'); } else { School::destroy($id); Session::flash('message', 'Sukses menghapus data sekolah!'); } }
/** * Remove the specified school from storage. * * @param int $id * @return Response */ public function destroy($id) { $sekolah = School::where('id', $id)->first(); // User::where('id', $sekolah->user_id)->delete($id); $data['activated'] = 0; User::where('id', $sekolah->user_id)->update($data); School::destroy($id); return Redirect::route('admin.daftarsekolah')->with('successMessage', 'Sekolah berhasil dihapus'); }