- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
32 lines
997 B
PHP
32 lines
997 B
PHP
<?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.');
|
|
}
|
|
}
|