<?php

namespace App\Http\Controllers;

use App\Models\News;
use Inertia\Inertia;

class NewsController extends Controller
{
    public function index()
    {
        $news = News::published()->latest('published_at')->paginate(9);

        return Inertia::render('News/Index', [
            'news' => $news,
        ]);
    }

    public function show(News $news)
    {
        abort_if(!$news->is_published, 404);

        return Inertia::render('News/Show', [
            'article' => $news,
        ]);
    }
}
