<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Anime;
use App\Models\Comment;
use App\Models\Episode;
use App\Models\Subscription;
use App\Models\User;

class DashboardController extends Controller
{
    public function index()
    {
        $stats = [
            'total_users'      => User::count(),
            'premium_users'    => User::where('membership', 'premium')->count(),
            'total_animes'     => Anime::count(),
            'total_episodes'   => Episode::count(),
            'total_comments'   => Comment::count(),
            'pending_comments' => Comment::where('status', 'pending')->count(),
            'active_subs'      => Subscription::where('status', 'active')->count(),
        ];

        $recent_users    = User::latest()->take(5)->get();
        $recent_comments = Comment::with('user')->latest()->take(5)->get();
        $recent_animes   = Anime::latest()->take(5)->get();

        return view('admin.dashboard', compact('stats', 'recent_users', 'recent_comments', 'recent_animes'));
    }
}
