'Laravel routes not working normally in custom files of routes [closed]

I use custom routes files in laravel 9 and I countered this problem:

The route return me to the home page when using route function in the link but it's work when I use url function, and the routes that not work are duplicated in the routes files

This is my files:

web

enter image description here

admin

enter image description here

in this case the show-alarms route not work when i use admin mode.



Solution 1:[1]

The route name can't be duplicated, in admin routes you need to update route name to be admin.show-alarms then you can use the new route name in blade

Solution 2:[2]

The problem is that:

I'm create a middleware to each file and when i request any route, LARAVEL search file by file if LARAVEL found the route it's check the middleware for this file and go ahead even i don't have the permissions and not check the other files, and the route it might be in another file where i have the permissions.

The solution is that:

i separate the common routes in another file and i make another middleware >that accept the common users Type.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayman Elmalah
Solution 2 Abdelkhalek Haddany