<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Api\BaseApiController;
use App\Models\Stats;
use Symfony\Component\HttpFoundation\Response;

class StatsController extends BaseApiController
{
    protected Stats $stats;

    public function __construct()
    {
        parent::__construct();
        $this->stats = model(Stats::class);
    }

    public function index()
    {
        try {
            $stats = $this->stats->findAll();
            return $this->success($stats, 'Statistics retrieved successfully');
        } catch (\Throwable $e) {
            log_message('error', 'Stats retrieval error: ' . $e->getMessage());
            return $this->respondError('Failed to retrieve statistics', Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }
}
