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

ginyrox's avatar

Middleware in Laravel 11

Hello everyone, I am new to PHP and Laravel. I started learning a few days ago. My goal is to create an internship management system for a university using Laravel 11. However, I am unable to create my own middlewares to implement an authentication system for 3 types of users: Yet I have manually created this middleware then when I called : )->middleware(['redirectUserMiddleware']); I got Target class [redirectUserMiddleware] does not exist.

0 likes
5 replies
vincent15000's avatar

Why do you need a middleware to redirect the users ?

Can explain the goal ?

1 like
ginyrox's avatar

@vincent15000 I want to create an authentication system for 3 types of users: user, admin and company using the jetstream middleware and with $table->string('usertype')->default('user'); from the table we will be able to redirect users on 3 routes (/dashboard, /home and /company) we will create 3 views for these routes with Bootstrap 5. thank you

1 like
vincent15000's avatar

@ginyrox Ok ... the authentication will be with a unique login form ? and then according the type of user, he will be redirected to the right page.

Are you using Fortify to handle the authentication ?

martinbean's avatar

I want to create an authentication system for 3 types of users: user, admin and company

@ginyrox Don’t. Use roles instead.

2 likes

Please or to participate in this conversation.