- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
34 lines
1 KiB
PHP
34 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Posts;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Posts\UpdatePostRequest;
|
|
use App\Models\CustomPostType;
|
|
use App\Models\Post;
|
|
use App\Services\PostService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
/**
|
|
* Controller for updating an existing post.
|
|
*/
|
|
class PostUpdateController extends Controller
|
|
{
|
|
/**
|
|
* Update the specified post.
|
|
*
|
|
* @param \App\Http\Requests\Admin\Posts\UpdatePostRequest $request
|
|
* @param \App\Models\CustomPostType $customPostType
|
|
* @param \App\Models\Post $post
|
|
* @param \App\Services\PostService $service
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function __invoke(UpdatePostRequest $request, CustomPostType $customPostType, Post $post, PostService $service): RedirectResponse
|
|
{
|
|
$service->updatePost($post, $request->validated());
|
|
|
|
return redirect()->route('admin.posts.index', $customPostType->slug)
|
|
->with('success', $customPostType->singular_name . ' updated successfully.');
|
|
}
|
|
}
|