Can laravel 5.5 horizon use controller method instead of closure?

Published 10 months ago by skeith22

I'm having problems handling the Horizon::auth() method in the routes. Can the method use a controller to handle the response?

the current code shows an error when you return false, but when you return true it's normal, it shows the horizon dashboard.

current code

Horizon::auth(function ($request) {
    if (TRUE) {
        return true;

    return false;

As far as I know you should do this check in a service provider and not in your controller. You should simply return true or false and that's it.

What are you trying to do exactly?


@bobbybouwmann I wanted to control where it goes instead of returning false


What do you mean with I wanted to control where it goes instead of returning false?


@bobbybouwmann what I mean is instead of just false could like return redirect? or return a view?

8 months ago (297,250 XP)

That method is for authorization so only true or false is valid as return types, just like Form Requests and the authorize() method.


Indeed, you can only return true or false there. You can do a redirect when you wrap everything in a middleware ;)

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