From 826ceb8f9b357a36024dbca59159ebebe804b560 Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 29 Aug 2024 13:41:06 +0200 Subject: [PATCH] #117 - fix: fixed updating news --- .../Dashboard/NewsManagementController.php | 3 ++- app/Http/Requests/NewsUpdateRequest.php | 17 +++++++++++++++++ app/Models/News.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/Http/Requests/NewsUpdateRequest.php diff --git a/app/Http/Controllers/Dashboard/NewsManagementController.php b/app/Http/Controllers/Dashboard/NewsManagementController.php index 96858d72..d99621ba 100644 --- a/app/Http/Controllers/Dashboard/NewsManagementController.php +++ b/app/Http/Controllers/Dashboard/NewsManagementController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use Inertia\Response; use Keating\Http\Requests\NewsRequest; +use Keating\Http\Requests\NewsUpdateRequest; use Keating\Models\News; class NewsManagementController @@ -53,7 +54,7 @@ public function edit(News $news): Response ]); } - public function update(NewsRequest $request, News $news): RedirectResponse + public function update(NewsUpdateRequest $request, News $news): RedirectResponse { $news->update($request->getData()); diff --git a/app/Http/Requests/NewsUpdateRequest.php b/app/Http/Requests/NewsUpdateRequest.php new file mode 100644 index 00000000..f65e230c --- /dev/null +++ b/app/Http/Requests/NewsUpdateRequest.php @@ -0,0 +1,17 @@ + $this->input("title"), + "content" => $this->input("content"), + "slug" => $this->slug, + ]; + } +} diff --git a/app/Models/News.php b/app/Models/News.php index f8d023dc..c4f05f30 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -33,7 +33,7 @@ class News extends Model protected $casts = [ "published_at" => "datetime:Y-m-d H:i", ]; - protected $Keatingends = [ + protected $appends = [ "published_at_formatted", ];