<?php

namespace App\Http\Controllers;

use App\Services\AdminMetricsService;
use Illuminate\Http\Request;

class AdminAnalyticsController extends Controller
{
    public function index(Request $request, AdminMetricsService $metrics)
    {
        [$period, $from, $to] = $metrics->rangeFromRequest($request);

        return view('admin.analytics.index', [
            'period' => $period,
            'from' => $from,
            'to' => $to,
            'data' => $metrics->analytics($from, $to),
        ]);
    }
}
