mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 10:06:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			689 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			689 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Traits\Services;
 | 
						|
 | 
						|
use App\Models\User;
 | 
						|
 | 
						|
trait HasUserLevels
 | 
						|
{
 | 
						|
    private int $userLevel = User::USER_LEVEL_USER;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Set the access level for running this function.
 | 
						|
     */
 | 
						|
    public function setUserLevel(int $level): self
 | 
						|
    {
 | 
						|
        $this->userLevel = $level;
 | 
						|
 | 
						|
        return $this;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Determine which level this function is running at.
 | 
						|
     */
 | 
						|
    public function getUserLevel(): int
 | 
						|
    {
 | 
						|
        return $this->userLevel;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Determine if the current user level is set to a specific level.
 | 
						|
     */
 | 
						|
    public function isUserLevel(int $level): bool
 | 
						|
    {
 | 
						|
        return $this->getUserLevel() === $level;
 | 
						|
    }
 | 
						|
}
 |