Home > Mobile >  How to solve this 404 Not Found error even though my route exist
How to solve this 404 Not Found error even though my route exist

Time:11-22

I have this route:

Route::get('orderview/{id}', [UserController::class, 'vieworder']);

and this is my form action:

 <td>
         <a href="{{ url('orderview/'.$item->id) }}" class="btn btn-primary">View</a>
 </td>

When ever i trigger this form action, it gives me Page not found and ive checked my route to confirm it the route is registered using:

php artisan route:list

ive also tried:

php artisan route:clear

php artisan route:cache 

php artisan config:clear

php artisan optimize

But this problem still persist, please i need help.

Sorry, this is controller:

public function vieworder($id)
{
    $orders = Order::where('id', $id)->where('user_id', Auth::id())->first();
    return view('frontend.orders.view', compact('orders'));
}

CodePudding user response:

Use the function in your router like this:

Route::get('orderview/{id}', '[ClassNameSpace]\UserController@vieworder')->name('orderview');

Update: [ClassNameSpace] should be changed to your customer/global target class's namespace :)

CodePudding user response:

Change your route to

Route::get('orderview/{id}', '[namespace]\UserController@vieworder')->name('orderview');;

and use route() in your href

href="{{ route('orderview',['id' => $item->id]) }}"
  • Related