<?php

namespace App\Modules\Transactions\Policies;

use App\Models\User;
use App\Models\Transaction;

class TransactionPolicy
{
    public function viewAny(User $user): bool
    {
        return true;
    }

    public function view(User $user, Transaction $transaction): bool
    {
        return $user->id === $transaction->user_id || $user->isAdmin();
    }

    public function refund(User $user, Transaction $transaction): bool
    {
        return $user->isAdmin() && in_array($transaction->status, ['successful', 'processing']);
    }
}
