缺少 [Route: showbilling] [URI: {locale}

我想这是我项目的最后一个问题。我在 1 个路由中有 2 个参数{locale}/projects/{id}/billings,问题是我在视图中传递了 2 个参数值,但它仍然提示缺少必需参数的错误。这是我的代码


网页.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');


});

项目.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>

项目控制器.php


public function showbilling($locale, $id){

   $billings = Project::find($id);

   //return $billings;

   return view('admin.addbillings', compact('billings'));

}


收到一只叮咚
浏览 115回答 2
2回答

ABOUTYOU

更新您将参数错误地传递给路由,您得到的错误是在路由器方法而不是控制器中生成的,正确设置路由器方法,它应该可以解决您的问题。Route::prefix('{locale}')->middleware('setlocale')->group(function(){&nbsp; &nbsp; Route::get('/projects/{id}/billings', 'ProjectController@showbilling')->name('showbilling');})->where('locale' => '[a-zA-Z]{2}');结果 URI /{locale}/project/{id}/billings

慕姐4208626

我认为你现在应该使用这个 URL:/{locale}/showbilling (例如:"as/showbilling") 而不是你现在使用的。{locale} 在路由器组中是有效的。所以,我猜你忘记了这个。
打开App,查看更多内容
随时随地看视频慕课网APP