<?php

namespace App\Http\Controllers\Website;

use App\Http\Controllers\Controller;
use App\Models\Loaders\NewsLoader;
use App\Views\NewsView;

class NewsController extends Controller
{
    public function __construct(
        private NewsLoader $newsLoader,
        private NewsView $view,
    ) {
        $this->addCssFile('news.css');
    }

    public function index()
    {
        $news = $this->newsLoader->getNews();
        $this->view->prepareData($news);


        return $this->render('news')
            ->with(compact('news'));
    }
}
