<?php

namespace App\Modules\Admin\Tenancy\Policies;

use App\Models\User;
use App\Modules\Admin\Tenancy\Models\Module;

class ModulePolicy
{
    public function before(User $user): ?bool
    {
        return $user->isAdmin() ? null : false;
    }

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

    public function view(User $user, Module $module): bool
    {
        return true;
    }

    public function create(User $user): bool
    {
        return true;
    }

    public function update(User $user, Module $module): bool
    {
        return true;
    }

    public function delete(User $user, Module $module): bool
    {
        return ! $module->plans()->exists();
    }
}
