我认为这是我项目的最后一个问题。我在1条路由{locale}/projects/{id}/billings
中有2个参数,问题是我在视图中传递了2个参数值,但仍提示缺少必需参数的错误。这是我的代码
web.php
Route::group(['prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function () {
Route::get('/', function () {
return view('welcome');
})->name('main');
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
//Customers
Route::get('/customers', 'CustomerController@showcust')->name('customers');
Route::post('/sendcust', 'CustomerController@sendcust')->name('sendcust');
//Items
Route::get('/items', 'ItemController@showitems')->name('items');
Route::post('/senditem', 'ItemController@senditem')->name('senditem');
//Projects
Route::get('/projects', 'ProjectController@showprojects')->name('projects');
Route::post('/sendproj', 'ProjectController@sendproj')->name('sendproj');
//ProjectBillings
Route::get('/projects/{id}/billings', 'ProjectController@showbilling')->name('showbilling');
Route::post('/sendbilling', 'ProjectController@addbilling')->name('sendbilling');
//Invoices
Route::get('/invoices', 'InvoiceController@showinvoice')->name('invoices');
Route::post('/sendinvoitem', 'InvoiceController@sendinvoitem')->name('sendinvoitem');
Route::get('/invoices/{id}/details', 'InvoiceController@showdetails');
Route::post('/updateitem','InvoiceController@updatedetail')->name('updateitem');
Route::get('invoices/{id}/generate', 'InvoiceController@generate');
Route::post('/updatestatus', 'InvoiceController@changestatus')->name('updatestatus');
});
projects.blade.php
<a href="{{route('showbilling', ['locale' => app()->getLocale(), 'id' => $cat->id])}}" class="btn btn-default btn-xs waves-effect waves-float waves-green"> {{__('Add Billing')}} </a>
ProjectController.php
public function showbilling($locale, $id){
$billings = Project::find($id);
//return $billings;
return view('admin.addbillings', compact('billings'));
}
答案 0 :(得分:0)
更新
您将参数错误地传递给了路由,正在获取的错误是在Router方法而不是在控制器上生成的,正确设置了router方法,应该可以解决您的问题。
Route::prefix('{locale}')->middleware('setlocale')->group(function(){
Route::get('/projects/{id}/billings', 'ProjectController@showbilling')->name('showbilling');
})->where('locale' => '[a-zA-Z]{2}');
结果URI / {locale} / project / {id} / billings
答案 1 :(得分:0)
我认为您现在应该使用以下URL:/ {locale} / showbilling(例如:“ as / showbilling”)。 {locale}在路由器组中很有效。所以,我想你会忘记这一点。