/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $club = getClub($id, 'admin::clubs'); ClubPost::where('club_id', $club->id)->delete(); Club::destroy($club->id); return Redirect::route('admin::clubs')->with('success', 'The club has been deleted'); }
/** * Remove the specified resource from storage. * * @param int $id * * @return mixed */ public function destroy($id) { $canBeDeleted = empty(Club::find($id)->teams->toArray()); if ($canBeDeleted) { Club::destroy($id); \Flash::success('Club deleted!'); } else { \Flash::error('Cannot delete because they are existing teams in this club.'); } return redirect('admin/data-management/clubs'); }