cms/app/Http/Controllers/Admin/Posts/PostStoreController.php

32 lines
997 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Controllers\Admin\Posts;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Posts\StorePostRequest;
use App\Models\CustomPostType;
use App\Services\PostService;
use Illuminate\Http\RedirectResponse;
/**
* Controller for storing a new post.
*/
class PostStoreController extends Controller
{
/**
* Store a newly created post.
*
* @param \App\Http\Requests\Admin\Posts\StorePostRequest $request
* @param \App\Models\CustomPostType $customPostType
* @param \App\Services\PostService $service
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(StorePostRequest $request, CustomPostType $customPostType, PostService $service): RedirectResponse
{
$service->storePost($customPostType, $request->validated());
return redirect()->route('admin.posts.index', $customPostType->slug)
->with('success', $customPostType->singular_name . ' created successfully.');
}
}