<?php

namespace App\Http\Controllers;

use App\Models\News;
use Illuminate\Http\Request;

class NewsController extends Controller
{
    

    public function index()
    {
    $allNews = News::latest()->paginate(10);

    return view('news.index', compact('allNews'));
    }
    
    public function showDetail($id)
    {
        // Cari berita, jika tidak ada maka tampilkan error 404
        $news = News::findOrFail($id);

        return view('news.news_detail', compact('news'));
    }
}