Skip to content

Commit

Permalink
#117 - fix: fixed updating news
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilpiech97 committed Aug 29, 2024
1 parent 2f34f50 commit 826ceb8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/Dashboard/NewsManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());

Expand Down
17 changes: 17 additions & 0 deletions app/Http/Requests/NewsUpdateRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Keating\Http\Requests;

class NewsUpdateRequest extends NewsRequest
{
public function getData(): array
{
return [
"title" => $this->input("title"),
"content" => $this->input("content"),
"slug" => $this->slug,
];
}
}
2 changes: 1 addition & 1 deletion app/Models/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];

Expand Down

0 comments on commit 826ceb8

Please sign in to comment.