<?php

namespace App\Policies;

use App\Models\Receipt;
use App\Models\User;

class ReceiptPolicy
{
    public function viewAny(User $user): bool
    {
        if (! $user->relationLoaded('role')) {
            $user->load('role');
        }

        return $user->hasRole('super-admin') || $user->hasRole('admin') || $user->hasRole('staff');
    }

    public function view(User $user, Receipt $receipt): bool
    {
        if (! $user->relationLoaded('role')) {
            $user->load('role');
        }

        return $user->hasRole('super-admin') || $user->hasRole('admin') || $user->hasRole('staff');
    }

    public function send(User $user, Receipt $receipt): bool
    {
        return $this->view($user, $receipt);
    }

    public function downloadPdf(User $user, Receipt $receipt): bool
    {
        return $this->view($user, $receipt);
    }
}
