<?php

namespace App\Http\Controllers\Panel;

use App\Http\Controllers\Controller;
use App\Models\Announcement;
use Illuminate\Support\Facades\Auth;

class PanelController extends Controller
{
    public function index()
    {
        $orders = Auth::user()
            ->orders()
            ->with([
                'items.product',
                'cancelRequests' => fn ($q) => $q->where('status', 'pending'),
            ])
            ->latest()
            ->take(3)
            ->get();

        $latestAnnouncement = Announcement::latest()->first();

        return view('panel.index', compact('orders', 'latestAnnouncement'));
    }
}
