<?php

namespace App\Modules\Sales\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\Sales\Models\SalesReturn;
use App\Support\Operational\SalesReturnOperationalPresenter;
use Illuminate\View\View;

final class SalesReturnPageController extends Controller
{
    public function show(SalesReturn $salesReturn): View
    {
        $this->authorize('view', $salesReturn);
        $salesReturn->load([
            'lines.salesOrderLine.inventoryItem',
            'salesOrder',
        ]);
        $operational = app(SalesReturnOperationalPresenter::class)->detail($salesReturn);

        return view('pages.sales.returns.show', [
            'return' => $salesReturn,
            ...$operational,
        ]);
    }
}
