Support the ongoing development of Laravel.io →
Authentication Session

Hi,

I'm creating a timesheet webapplication where only registered users can have access. Offcourse admins should also have the same permissions + additional features.

So the idea is to have 2 filters.

An "auth" and an "admin" filter. As for the admin filter you need to be logged in first.

So the question is should I repeat myself and create in both filters an Auth::check() or extend the auth filter for the admin? Is it also possible to extend filters?

Last updated 2 years ago.
0
Solution

You can simply apply two (auth|admin) filters to your admin routes.

And in admin filter, just check if user is a admin because log in is already checked by auth filter.

Last updated 2 years ago.
0

Thank you, I should have payed more attention to the documentation :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

goowikns goowikns Joined 18 Jun 2014

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.