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

amitvik's avatar

Gate::allows() function not working in API routes

Gate::allow not working in API routes using auth:api middleware. Is there a way to solve it

0 likes
3 replies
amitvik's avatar

solved using Auth::guard('web')->user() and using a custom method in User Model solved the issue

ycsm's avatar

May I ask - this is a long time ago I know, but do you have the full code you used to get this working?

Please or to participate in this conversation.