cms/app/Http/Controllers/Admin/Posts/PostDestroyController.php
Funky Waddle 37ed997989 feat(cms): initialize Laravel project structure and core CMS files
- Added standard Laravel directory structure and configuration.

- Included Svelte and Tailwind configuration for the admin interface.

- Added core PHPUnit and testing scripts.
2026-04-13 12:48:06 -05:00

35 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Posts;
use App\Http\Controllers\Controller;
use App\Models\CustomPostType;
use App\Models\Post;
use App\Services\PostService;
use Illuminate\Http\RedirectResponse;
/**
* Controller for deleting an existing post.
*/
class PostDestroyController extends Controller
{
/**
* Remove the specified post.
*
* @param \App\Models\CustomPostType $customPostType
* @param \App\Models\Post $post
* @param \App\Services\PostService $service
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(CustomPostType $customPostType, Post $post, PostService $service): RedirectResponse
{
if ($service->deletePost($post)) {
return redirect()->route('admin.posts.index', $customPostType->slug)
->with('success', $customPostType->singular_name . ' deleted successfully.');
}
return redirect()->route('admin.posts.index', $customPostType->slug)
->with('error', 'Failed to delete ' . $customPostType->singular_name . '.');
}
}