'Laravel 404 not found when passing parameter with route()
Hello I have instructors table, and every instructor have name column and I have a page to show events and every event has instructor name and I need to go to the instructor profile page when clicking on the instructor name in the events page so I made this
<a href="{{ route('instructor.profile', ['name' => $event->instructor]) }}" class="a-reset">
<h5 class="color-primary fw-bold">{{ $event->instructor }}</h5>
</a>
web.php
Route::get('/instructor/{name}', 'App\Http\Controllers\InstructorController@profile')->name('instructor.profile');
InstructorController
public function profile($name) {
$instructor = Instructor::where('name', '=', $name)->first();
return view('instructor-profile', compact('instructor'));
}
But it gives me 404 Not Found error page
Solution 1:[1]
- Make sure it returns value $event->instructor
- Make sure the address is correct instructor-profile
- by this command rtisan route:list open route list, make sure it is there /instructor/{name} route.
- if everything is correct run this command
php artisan route:clear
php artisan config:cache
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 |
