Laravel NotFoundHttpException

I am new to laravel. I am trying to link to another page. I have a page index and you want to go on to the description of the vehicle information selected on the index page. The problem is that it shows an error:

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

index.blade.php @foreach ($cars as $car) <tr> <td> {{link_to_action(' CarController@show ', $car->Description, $car->id)}}</td> {{ Form::open(array('action' => ' CarController@show ', $car->id)) }} {{ Form::close() }} <td>{{ $car->License }}</td> <td>{{ $car->Milage }}</td> <td>{{ $car->Make }}</td> <td>{{ $car->status }}</td> </tr> @endforeach 

routes.php

 Route::resource('/', 'CarController'); Route::resource('create', 'DataController'); Route::post('desc', array('uses' => ' CarController@show ')); Route::post('create', array('uses' => ' CarController@create ', 'uses' => ' DataController@index ')); Route::post('update', array('uses' => ' CarController@update ')); Route::post('store', array('store' => ' CarController@store ')); 
+7
php laravel-4
source share
1 answer

"NotFoundHttpException" means that Laravel could not find the route for the request.

Your desc route is just a POST route, and link_to_action will create a GET request, so you may need to change the addition of the GET route too:

 Route::post('desc', array('uses' => ' CarController@show ')); Route::get('desc', array('uses' => ' CarController@show ')); 

There is also any that does GET, POST, PUT, DELETE:

 Route::any('desc', array('uses' => ' CarController@show ')); 

If you need to get id from your route, you will have to add it as a parameter:

 Route::post('car/{id}', array('uses' => ' CarController@show ')); 

And you will have to access your page as:

 http://myappt.al/public/car/22 

But if you want to access it like:

 http://myappt.al/public/22 

You will need to do:

 Route::post('{id}', array('uses' => ' CarController@show ')); 

But this is dangerous because it can capture all the routes, so you MUST set it as the most recent route .

And your controller should accept this parameter:

 class CarController extends Controller { public function show($id) { dd("I received an ID of $id"); } } 

EDIT:

Since you use most of your routes manually, you can also go with the index as follows:

 Route::resource('create', 'DataController'); Route::get('/', ' CarController@index '); Route::post('create', array('uses' => ' CarController@create ','uses' => ' DataController@index ')); Route::post('update', array('uses' => ' CarController@update ')); Route::post('store', array('store' => ' CarController@store ')); Route::get('{id}', array('uses' => ' CarController@show ')); Route::post('{id}', array('uses' => ' CarController@show ')); 
+9
source

All Articles