Reputation: 47
I recently started to code my own Admin panel in Laravel. Every route was working fine, but all of a sudden the /admin route inside the Auth middleware group stopped working properly.
This are my routes inside web.php
And the EntryController@index looks like this:
public function index()
{
//
$entries = Entry::all();
return view('admin.index', ['entries' => $entries]);
}
I'm having this problem for about 2 now, so maybe one of you know the solution.
Upvotes: 1
Views: 287
Reputation: 111
I think you're having this issue because of how Laravel prioritises its routes.
And I think the culprit might be this route:
Route::get('/{link}', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
When you use {link}
you are basically saying: "expect anything in this segment of the URI". Since the /{link}
route is placed before the /admin
route, and their URIs both contain only one segment, Laravel will try to resolve /{link}
first.
Solution: just move the /{link}
route below the /admin
route. Might be best to just place it at the bottom of the list :D
Upvotes: 0