<?php

namespace App\Modules\HR\Analytics\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\HR\Analytics\Services\HrAnalyticsService;
use Illuminate\View\View;

class HrAnalyticsPageController extends Controller
{
    public function __construct(private readonly HrAnalyticsService $analytics) {}

    public function index(): View
    {
        $user = auth()->user();
        abort_unless(
            $user?->can('employees.view') && $user?->can('attendance.view'),
            403,
        );

        return view('pages.hr.analytics.index', [
            'analytics' => $this->analytics->dashboard((int) $user->tenant_id),
        ]);
    }
}
