<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\PackagePurchase;
use App\Models\User;

class PackagePurchasePolicy
{
    /**
     * Package checkout is reached by reference, same as a booking. Without
     * this, altering the URL would show somebody else's purchase and the
     * payment reference attached to it.
     */
    public function view(User $user, PackagePurchase $purchase): bool
    {
        return $purchase->user_id === $user->id || $user->isAdmin();
    }
}
