<?php
// app/View/Components/Navigation.php
namespace App\View\Components;

use App\Models\File;
use App\Models\Category;
use App\Models\Stage;
use App\Models\FileStage;
use App\Models\NoticeUpdate;
use App\Models\FileAttachment;
use App\Models\User;
use App\Models\AttachmentType;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\Component;

class Navigation extends Component
{
    public $counts;
    public $user;

    public function __construct()
    {
        $this->loadCounts();
        $this->user = Auth::user();
    }

    protected function loadCounts()
    {
        $this->counts = [
            'files' => File::count(),
            'categories' => Category::count(),
            'stages' => Stage::count(),
            'assignments' => FileStage::count(),
            'notices' => NoticeUpdate::count(),
            'attachments' => FileAttachment::count(),
            'users' => User::count(),
            'attachment_types' => AttachmentType::count(),
        ];
    }

    public function isActive($route)
    {
        return request()->routeIs($route) ? 'active' : '';
    }

    public function render()
    {
        return view('components.navigation');
    }
}