<?php

namespace App\Http\Controllers;

use App\Models\Auction;
use App\Models\Lot;
use Illuminate\Http\Request;

class AuctionController extends Controller
{
    public function index()
    {
        $featured = Lot::where('is_featured', true)
            ->where('status', 'live')
            ->with('media')
            ->take(8)
            ->get();

        $auctions = Auction::where('status', 'live')->orWhere('status', 'published')->get();

        return view('auctions.index', compact('featured', 'auctions'));
    }

    public function show(Lot $lot)
    {
        $lot->load(['bids.user', 'auction', 'media']);
        $related = Lot::where('auction_id', $lot->auction_id)
            ->where('id', '!=', $lot->id)
            ->where('status', 'live')
            ->take(4)
            ->get();

        return view('auctions.show', compact('lot', 'related'));
    }

    public function liveDisplay(Auction $auction)
    {
        // Full-screen live display – no chrome
        return view('auctions.live-display', compact('auction'));
    }
}
