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

29 lines
734 B
PHP
Raw Normal View History

<?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(),
]);
}
}