<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Blog; // ← WAJIB DITAMBAHKAN
use App\Models\Photo;
use App\Models\Video;
use App\Models\Hero;
use App\Models\Ekskul;


class AppController extends Controller
{
    // public function index()
    // {
    //     return view('welcome', [
    //         'artikels' => Blog::orderBy('id', 'desc')->limit(3)->get(),
    //         'videos' => Video::orderBy('id', 'desc')->limit(3)->get(),
    //         'photos' => Photo::orderBy('id', 'desc')->limit(4)->get(),
    //     ]);
    // }
    public function index()
    {
        return view('welcome', [
            'heroes'   => Hero::where('status', 1)->orderBy('id', 'desc')->get(),
            'artikels' => Blog::orderBy('id', 'desc')->limit(3)->get(),
            'videos'  => Video::orderBy('id', 'desc')->limit(3)->get(),
            'photos'  => Photo::orderBy('id', 'desc')->limit(4)->get(),
            'ekskuls'  => Ekskul::orderBy('id', 'desc')->limit(4)->get(),
        ]);
    }


    public function berita()
    {
        return view('berita.berita', [
            'artikels' => Blog::orderBy('id', 'desc')->get()
        ]);
    }

    public function detail($slug)
    {
        $artikel = Blog::where('slug', $slug)->first();
        return view('berita.detail', [
            'artikel' => $artikel
        ]);
    }
}
