Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SirIsaac's avatar

Laravel Auth Guest Problem

In my App\User Model i have these two methods:

public function getPermissions()
    {
        if (!Auth::guest()) {
           // returns array
            }
        }
        return null;
    }

    public function isMedStaff()
    {
        if (!Auth::guest()) {
            // retuns true or false
        }
        return null;
    }

On my local laragon these two methods work without any problem, but when i deploy them to my staging server, then some strange happens. The getPermissions() method retuns the permissions array as i want, but the isMedStaff() method return null. In both cases i am loggedin in my website. I dont understand, what the problem there is.

0 likes
1 reply
MohamedTammam's avatar

isMedStaff method will return null if the user is logged in.

Why don't you type it that way?

public function isMedStaff()
    {
		// Will return true if the user is logged in, false otherwise.
        return !Auth::guest();
		// Another way to achieve the same result.
		return Auth::check();
    }

PS: the code isn't tested.

Please or to participate in this conversation.