Remove the Anchor tag $category->id and then try ..
It showing you the 404 error because of the $category variable because you have not passed the data into your views blade file through the controller..
Oct 5, 2022
8
Level 3
Why is this giving me a 404 error
Here's my code;
web.php
Route::prefix('employee')->middleware('auth')->group(function (){
Route::prefix('categories')->middleware('auth')->group(function (){
Route::get('details/{$id}', 'App\Http\Controllers\CategoryController@showDetails')->name('categories.details');
}};
I also tried;
Route::get('details/{$id}',[ 'App\Http\Controllers\CategoryController', 'showDetails'])->name('categories.details');
my link :
<a href="{{ route('categories.details', $category->id) }}" class="btn btn-primary btn-sm">Details</a>
in my categorycontroller :
public function showDetails($id){
dd("helo");
}
Error :
404 | NOT FOUND
Route does show up on php artisan route:list
GET|HEAD employee/categories/details/{$id} ........... categories.details › CategoryController@showDetails
Level 75
Do you have $ in your route definition? If so remove it.
It has to be like this:
Route::get('details/{id}', 'App\Http\Controllers\CategoryController@showDetails')->name('categories.details');
2 likes
Please or to participate in this conversation.