v0.10.18 - When deleting a menu, guide or event - The news according to the menu,guide or event will also get deleted (correctly now)

This commit is contained in:
Anders 2020-08-31 12:48:59 +02:00
parent 56cdd63fbb
commit b6f4fdb138
3 changed files with 16 additions and 10 deletions

View File

@ -233,9 +233,8 @@ class EventController extends Controller
$userEvent->delete(); $userEvent->delete();
} }
$news = News::query()->where("type_id", "=", "3")->where("arrangement_id", "=", $event->id)->first(); $news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where("type", "=", "Activity")->where("arrangement_id", "=", $id);
if($news !== null) $news->delete();
$news->delete();
$event->delete(); $event->delete();

View File

@ -159,17 +159,18 @@ class GuideController extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param Guide $guide * @param Guide $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($guide) public function destroy($id)
{ {
$guide = Guide::find($guide); // Find the guide you want to remove
$news = News::query()->where("type_id", "=", "4")->where("arrangement_id", "=", $guide->id)->first(); $guide = Guide::find($id);
// Find the news the you made when creating the guide (if there is a news)
if($news !== null) $news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where("type", "=", "Guide")->where("arrangement_id", "=", $id);
$news->delete();
//Delete the news or/and guide
$news->delete();
$guide->delete(); $guide->delete();

View File

@ -193,7 +193,13 @@ class MenuPlanController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
// Find the menu you want to remove
$menuplan = MenuPlan::find($id); $menuplan = MenuPlan::find($id);
// Find the news the you made when creating the menu (if there is a news)
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where('type', '=', 'Menu')->where('arrangement_id', '=', $id);
//Delete the news or/and menu
$news->delete();
$menuplan->delete(); $menuplan->delete();
return redirect()->route("menu-plans.index"); return redirect()->route("menu-plans.index");
} }