VenomRush
VenomRush

Reputation: 1682

Action not defined - ErrorException in UrlGenerator.php line 605

I'm getting the following error: ErrorException in UrlGenerator.php line 605: Action App\Http\Controllers\VehicleController@processLead not defined.

I've checked if the route exists by using the command php artisan route:list and it does.

routes\web.php

<?php

use App\Http\Controllers\BaseController;
use App\Http\Controllers\VehicleController;
use App\Http\Requests\ValidateLeadValues;
use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', 'IndexController@index');
Route::get('usedcars/', 'VehicleController@index');
Route::post('processLead/{id}', function ($id, ValidateLeadValues $leadValues, VehicleController $vehicleController)
{
    return $vehicleController->processLead($id, $leadValues);
})->where(['id' => '[0-9]+']);

I have the following inside my view file. The code is in my form's action and when I remove it, the page loads fine.

{{ action('VehicleController@processLead', ['id' => $vehicle->id]) }}

Upvotes: 1

Views: 1744

Answers (1)

Anton Grigorov
Anton Grigorov

Reputation: 139

Do you have in the App\Http\Controllers\VehicleController a public method processLead?

Try changing the view to {{ url('processLead', [$vehicle->id]) }}

I think the problem occurs, because the route is not registered directly with the controller method.

Upvotes: 1

Related Questions