<?php

namespace App\Http\Controllers\Earn;

use App\Http\Controllers\Controller;
use Illuminate\View\View;

class EarnDashboardController extends Controller
{
    public function __invoke(): View
    {
        $member = auth('earn')->user();
        $activeTokenCount = $member->tokens()
            ->where(fn ($query) => $query->whereNull('expires_at')->orWhere('expires_at', '>', now()))
            ->count();

        return view('earn-panel.dashboard', compact('member', 'activeTokenCount'));
    }
}
