DoeJohn
116
4
Laravel

How to add a new (custom) function that can be chained with the auth() function

Posted 3 months ago by DoeJohn

As stated in the documentation, the auth() function can be used instead of the Auth facade, returns an authenticator instance and can be used like this:

    auth()->check() 
    auth()->guest()
    auth()->id() 
    auth()->user()

As you can see - I can chain ->check() or ->guest() or ->id() or ->user().

Is it possible to add a new custom function that can be also chaned? For example, somethingNew() that can be used like this:

    auth()->somethingNew() // returns boolean

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.