<?php
namespace App\Controllers\Admin;

use App\Models\Product;
use App\Models\Category;
use App\Models\News;
use App\Models\Banner;
use App\Models\Setting;

class DashboardController extends AdminController
{
    public function index()
    {
        $setting = new Setting();
        $data = [
            'site_name' => $setting->get('site_name', '酷冰甲 · 降温服'),
            'counts'    => [
                'products'   => (new Product())->count(),
                'categories' => (new Category())->count(),
                'news'       => (new News())->count(),
                'banners'    => (new Banner())->count(),
            ],
            'news' => (new News())->published(5),
        ];
        return $this->view('admin/dashboard', $data);
    }
}
