操作未定义 - UrlGenerator.php第605行中的ErrorException

时间:2017-01-30 08:01:05

标签: php routes laravel-5.3

我收到以下错误:UrlGenerator.php第605行中的ErrorException:操作App \ Http \ Controllers \ VehicleController @ processLead未定义。

我已经使用command php artisan route:list检查了路线是否存在,而且确实存在。

路由\ 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]+']);

我的视图文件中有以下内容。代码是我的表单的动作,当我删除它时,页面加载正常。

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

1 个答案:

答案 0 :(得分:1)

你在App \ Http \ Controllers \ VehicleController中有一个公共方法processLead吗?

尝试将视图更改为{{url('processLead',[$ vehicle-&gt; id])}}

我认为问题出现了,因为路径没有直接用控制器方法注册。