<?php

namespace $NAMESPACE$\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use $NAMESPACE$\Models\$PACKAGE_NAME$Item;

class DashboardController extends Controller
{
    public function index(Request $request)
    {
        if(Auth::user()->can('manage-$PACKAGE_KEBAB$')){
            $totalItems = $PACKAGE_NAME$Item::where('created_by', creatorId())->count();
            $activeItems = $PACKAGE_NAME$Item::where('created_by', creatorId())->where('is_active', true)->count();
            $recentItems = $PACKAGE_NAME$Item::where('created_by', creatorId())->latest()->take(5)->get();

            return Inertia::render('$PACKAGE_NAME$/Index', [
                'stats' => [
                    'total_items' => $totalItems,
                    'active_items' => $activeItems,
                    'inactive_items' => $totalItems - $activeItems,
                ],
                'recent_items' => $recentItems,
                'message' => __('$PACKAGE_NAME$ Dashboard - Manage your items efficiently.')
            ]);
        }
        return back()->with('error', __('Permission denied'));
    }
}