<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Blog\Post;
use Illuminate\Http\Request;

class PostController extends Controller
{
    public function index()
    {
        $posts = Post::with(['author', 'category'])->latest()->paginate(10);
        return view('admin.blog.posts.index', compact('posts'));
    }

    public function create()
    {
        $categories = \App\Models\Blog\Category::all();
        $authors = \App\Models\Blog\Author::all();
        return view('admin.blog.posts.create', compact('categories', 'authors'));
    }

    public function edit(Post $post)
    {
        $categories = \App\Models\Blog\Category::all();
        $authors = \App\Models\Blog\Author::all();
        return view('admin.blog.posts.edit', compact('post', 'categories', 'authors'));
    }
}
