/** * Remove season. * * @param int $id * @return Response */ public function destroy($season_id) { Season::destroy($season_id); Team::where('season_id', $season_id)->delete(); Fixture::where('season_id', $season_id)->delete(); LeagueTable::where('season_id', $season_id)->delete(); return response()->json(['success' => true]); }
/** * Remove the specified resource from storage. * * @param int $id * * @return mixed */ public function destroy($id) { $canBeDeleted = empty(Season::find($id)->divisions->toArray()); if ($canBeDeleted) { Season::destroy($id); \Flash::success('Season deleted!'); } else { \Flash::error('Cannot delete because they are existing divisions in this season.'); } return redirect('admin/data-management/seasons'); }