How to pass more than one Can middleware in the Aravel?

Asked

Viewed 88 times

0

Hello, I need to pass several defines for a route, for example admin, annual plan, and new-user, when I put can in middleware it only identifies the first parameter.

Authserviceprovider.php

Gate::define("new-user","App\Policies\ACLChecker@checkerNewUser");
        Gate::define("plano-anual","App\Policies\ACLChecker@checkerPlanoAnual");
Gate::define("admin","App\Policies\ACLChecker@checkerAdmin");

web php.

Route::get('/home', 'HomeController@index')->middleware("can:plano-anual,new-user,admin");

Debug:

Gate::after(function ($user, $ability, $result, $arguments) {
            //
            dd($user->plano, $ability, $result, $arguments);

        });
  • Mano o can on the route works like this,the first is the name of the action we want to authorize and the second is the route parameter we wish to pass to the policy method.

  • I need to have control of these categories in the layout, is there another way to make them? @Joanmarcos

  • More to lock user who does not make payment.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.