In my Laravel 7 project project I've got two controllers. One for the frontend and one for the backend pages.
The routes are defined as follows:
<?php
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get( '/', 'PageController@index' );
Route::get( '/login', 'Auth\LoginController@showLoginForm' );
Route::get( '/logout', 'Auth\LoginController@logout' );
Route::get( '/register', 'Auth\RegisterController@showRegistrationForm' );
Route::get( '/{slug}', 'PageController@show' );
Auth::routes();
Route::get( '/admin', 'HomeController@index' )->name( 'home' );
However when I try to acces the admin route, it's using the pageController@show method instead of the homeController@index as seen below:
I've tried using groups with prefixes of "admin" and then pages like admin/dashboard use the right controller but still the admin route on itself does not.
I've looked at multiple examples of route files but they don't seem to work for me.
I suspect it's got something to do with the fact that I use dynamic routes? But than again all the other routes work fine so I don't really see the problem here...
How can I fix this?
/{slug}
so its think admin one slug. Move your admin codes before slug – xNoJustice/{slug}
will capture everything there, so you need to put your admin route before it. – Kurt Friars