- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
29 lines
734 B
PHP
29 lines
734 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Posts;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\CustomPostType;
|
|
use App\Models\Post;
|
|
use Illuminate\View\View;
|
|
|
|
/**
|
|
* Controller for listing posts for a specific CPT.
|
|
*/
|
|
class PostIndexController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of posts for a specific CPT.
|
|
*
|
|
* @param \App\Models\CustomPostType $customPostType
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function __invoke(CustomPostType $customPostType): View
|
|
{
|
|
return view('admin.posts.index', [
|
|
'customPostType' => $customPostType,
|
|
'posts' => Post::where('custom_post_type_id', $customPostType->id)->with('author')->get(),
|
|
]);
|
|
}
|
|
}
|