HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/slenders.komma.pro/app/Komma/Users/Models/KmsUserRoleOld.php
<?php

namespace App\Komma\Users\Models;

use App\Komma\Kms\Core\Attributes\Models\Traits\HasThumbnailInterface;
use App\Komma\Kms\Core\Attributes\Models\Traits\HasThumbnailTrait;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Komma\Users\Models\Role
 *
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Users\Models\KmsUser[] $users
 * @mixin \Eloquent
 * @property int $id
 * @property string $name
 * @property int $value
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld whereValue($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Users\Models\KmsUserRoleOld query()
 */
final class KmsUserRoleOld extends Model implements HasThumbnailInterface
{
    use HasThumbnailTrait;

    const SuperAdmin = 1;
    const Admin = 2;
    const Editor = 3;
    const Customer = 4;

    protected $kmsClass = KmsUserRoleOld::class;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'roles';


    protected $fillable = ['name', 'value'];

    public function kmsUsers()
    {
        return $this->hasMany(KmsUser::class);
    }

    public function siteUsers()
    {
        return $this->hasMany(SiteUser::class);
    }

    /**
     * Checks if the specified compare value is
     *
     * @param null|int|KmsUserRoleOld $compare
     * @return bool
     */
    public function isAtLeast($compare = null)
    {
        if($compare == null) return true;
        elseif(is_numeric($compare))
            return $this->value <= $compare;
        elseif(is_a($compare, KmsUserRoleOld::class))
            return $this->value <= $compare->value;
    }

    /**
     * @return int[] All roles as an array of integers
     */
    static function getAsArray() {
        return self::getAllRoles();
    }

    /**
     * Returns an array containing integers representing the defined roles.
     *
     * @return int[]
     */
    private static function getAllRoles()
    {
        $thisClassAsReflectionClass = new \ReflectionClass(__CLASS__);
        return $thisClassAsReflectionClass->getConstants();
    }

    /**
     * Returns the value of the role as a string
     *
     * @return string
     */
    public function __toString()
    {
        return $this->value;
    }
}