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/ASmits/kemi.nl/app/KommaApp/Users/Models/Role.php
<?php

namespace App\KommaApp\Users\Models;

use Illuminate\Database\Eloquent\Model;

class Role extends Model {

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

    protected $kmsClass = Role::class;

    /*
    * Transient properties on Eloquent models
    * These are not saved to database.
    */
    public $thumbnail = false;


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


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

    public function users()
    {
        return $this->hasMany(User::class);
    }

    public function isAtLeast($compare)
    {
        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();
    }
}