<?php
namespace App\Http\Controllers\Api\V1;
use App\Enums\TransferStatus;use App\Http\Controllers\Controller;use App\Http\Resources\TransferResource;use App\Models\Transfer;use Illuminate\Http\Request;
class PayoutController extends Controller {public function index(Request $r){$q=Transfer::whereIn('status',[TransferStatus::Redeemed,TransferStatus::Settled]);if(!$r->user()->hasRole('admin'))$q->where('receive_merchant_id',$r->user()->merchant_id);return TransferResource::collection($q->latest('redeemed_at')->paginate(min($r->integer('per_page',20),100)));}public function show(Request $r,Transfer $transfer){$this->authorize('view',$transfer);abort_unless(in_array($transfer->status,[TransferStatus::Redeemed,TransferStatus::Settled],true),404);return new TransferResource($transfer->load('events'));}public function receipt(Request $r,Transfer $transfer){return $this->show($r,$transfer);}}
