<?php

namespace App\Http\Controllers\Coach;

use App\Http\Controllers\Controller;
use App\Models\Payment;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;

class PaymentReceiptController extends Controller
{
    /**
     * سرو امن رسید — فقط طرفین (ورزشکار/مربیِ همان درخواست) و Admin.
     */
    public function show(Payment $payment): StreamedResponse
    {
        $this->authorize('view', $payment);

        return Storage::disk('local_private')->response(
            $payment->receipt_path,
            $payment->receipt_original_name,
            ['Content-Type' => $payment->receipt_mime_type]
        );
    }
}
