From 5bff8d70a0b246cafbbc102b28baa1d75e43fb86 Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Tue, 26 Apr 2022 19:13:53 -0700 Subject: [PATCH] destroy joined --- app/Http/Controllers/JoinedController.php | 2 ++ app/Models/Joined.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/JoinedController.php b/app/Http/Controllers/JoinedController.php index fdaf961..b9daa19 100644 --- a/app/Http/Controllers/JoinedController.php +++ b/app/Http/Controllers/JoinedController.php @@ -44,5 +44,7 @@ public function update(UpdateJoinedRequest $request, Joined $joined) public function destroy(Joined $joined) { + $joined->remove(); + return redirect()->route('admin.joined.index')->with('success', 'Fanlisting removed.'); } } diff --git a/app/Models/Joined.php b/app/Models/Joined.php index a6ecd5a..b031d8b 100644 --- a/app/Models/Joined.php +++ b/app/Models/Joined.php @@ -84,4 +84,12 @@ public function patch(array $validated) : Joined return $this; } + + /* ------------------------------------------------------------------------------ remove ---- */ + + public function remove() : void + { + $this->categories()->detach(); + $this->delete(); + } }