Support the ongoing development of Laravel.io →
Blade Authentication

I would like to access a column called "access_level" in table "roles". The thing now is that I wanted to avoid middlewares as it needs to be executed (checked) on every page load, what implies passing the same middleware to every route. Now I could query it and passing it to every route which is somehow same as passing the same middleware. In order to avoid that passing and exclude logic from blade, I was thinking to extend the Auth Facade simply with a method that returns the access level. From that point I can just say @if (Auth::getAccessLevel > 3) ... @endif.

Now I want your opinion on this, how good approach is this? I wanna be able to show certain parts of the website according to the user's access level.

Iff it is a good approach, why my method implemented in GuardHelpers.php isn't visible? Most of the Auth methods are implemented there.

Thanks!

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

proph37 proph37 Joined 11 May 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.