<?php

namespace App\Http\Controllers;

use App\Models\Transfer;
use Illuminate\Http\Request;

class AdminController extends Controller
{
    public function dashboard()
    {
        $totalTransfers = Transfer::count();
        $pendingTransfers = Transfer::where('status', 'pending')->count();
        $completedTransfers = Transfer::where('status', 'completed')->count();
        $totalAmountUSD = Transfer::where('status', 'completed')->where('currency', 'USD')->sum('amount');
        $totalAmountSYR = Transfer::where('status', 'completed')->where('currency', 'SYR')->sum('amount');
        $recentTransfers = Transfer::with('creator')->orderBy('created_at', 'desc')->take(10)->get();

        return view('admin.dashboard', compact(
            'totalTransfers',
            'pendingTransfers',
            'completedTransfers',
            'totalAmountUSD',
            'totalAmountSYR',
            'recentTransfers'
        ));
    }
}
