PHP Classes

File: src/Models/UserRank.php

Recommend this page to a friend!
  Classes of Mateo   Ollama Artificial Intelligence PHP Telegram Bot   src/Models/UserRank.php   Download  
File: src/Models/UserRank.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Ollama Artificial Intelligence PHP Telegram Bot
Telegram bot to interact with Ollama AI models
Author: By
Last change:
Date: 11 months ago
Size: 467 bytes
 

Contents

Class file image Download
<?php

namespace Mateodioev\OllamaBot\Models;

enum UserRank: int
{
    case
Banned = 1;
    case
User = 2;
    case
Admin = 3;
    case
Owner = 4;

   
/**
     * Check if the rank has the permission
     */
   
public static function hasPermission(User $user, UserRank $permission): bool
   
{
        return
$user->rank >= $permission;
    }

    public static function try(
int $id): UserRank
   
{
        return
UserRank::tryFrom($id) ?? UserRank::User;
    }
}