<?php

namespace App\Modules\Exports\Policies;

use App\Models\User;
use App\Modules\Exports\Models\Export;

class ExportPolicy
{
    public function viewAny(User $user): bool
    {
        return $user->can('exports.access');
    }

    public function view(User $user, Export $export): bool
    {
        if (! $user->can('exports.access')) {
            return false;
        }

        return (int) $user->tenant_id === (int) $export->tenant_id;
    }

    public function create(User $user): bool
    {
        return $user->can('exports.access');
    }

    public function download(User $user, Export $export): bool
    {
        return $this->view($user, $export);
    }
}
