app\Models\Access\User\Traits\UserAccess::allow PHP 메소드

allow() 공개 메소드

Check if user has a permission by its name or id.
public allow ( string $nameOrId ) : boolean
$nameOrId string Permission name or id.
리턴 boolean
    public function allow($nameOrId)
    {
        foreach ($this->roles as $role) {
            // See if role has all permissions
            if ($role->all) {
                return true;
            }
            // Validate against the Permission table
            foreach ($role->permissions as $perm) {
                // First check to see if it's an ID
                if (is_numeric($nameOrId)) {
                    if ($perm->id == $nameOrId) {
                        return true;
                    }
                }
                // Otherwise check by name
                if ($perm->name == $nameOrId) {
                    return true;
                }
            }
        }
        return false;
    }