<?php

namespace Modules\Admin\Http\Policies;

use Modules\User\Models\User;
use Modules\User\Models\UserRole;
use Modules\User\Models\Role;

class AdminPathPolicy
{
    public function viewAdminPath(User $user): bool
    {
        if (
            UserRole::where('user_id', $user->id)->where('role_id', Role::SUPER_ADMIN)->count() == 1
            || UserRole::where('user_id', $user->id)->where('role_id', Role::CITY_MANAGER)->count() == 1
        )
        {
            return true;
        }
        return false;
    }

    public function editGlobalTables(User $user): bool
    {
        if (
            UserRole::where('user_id', $user->id)->where('role_id', Role::SUPER_ADMIN)->count() == 1
        )
        {
            return true;
        }
        return false;
    }
}
