我已经在routes.php中创建了一条路线
Route::group(['prefix' => 'quotation'], function () {
Route::get('data', 'QuotationController@data');
Route::post('send_quotation', 'QuotationController@sendQuotation');
Route::get('{quotation}/show', 'QuotationController@show');
Route::get('{quotation}/edit', 'QuotationController@edit');
Route::get('{quotation}/delete', 'QuotationController@delete');
Route::get('{quotation}/ajax_create_pdf', 'QuotationController@ajaxCreatePdf');
Route::get('{quotation}/print_quot', 'QuotationController@printQuot');
Route::get('{quotation}/make_invoice', 'QuotationController@makeInvoice');
Route::get('{quotation}/approve', 'QuotationController@approve');
Route::get('{quotation}/confirm_sales_order', 'QuotationController@confirmSalesOrder');
Route::put('{quotation}', 'QuotationController@update');
Route::delete('{quotation}', 'QuotationController@destroy');
Route::get('ajax_qtemplates_products/{qtemplate}', 'QuotationController@ajaxQtemplatesProducts');
Route::get('ajax_sales_team_list', 'QuotationController@ajaxSalesTeamList');
Route::get('draft_quotations_list/data', 'QuotationController@draftQuotations');
Route::get('draft_quotations', 'QuotationController@draftIndex');
});
Route::resource('quotation', 'QuotationController');
但是当我运行url时:
quotation/34/edit
然后显示错误:
Page not Found
请帮助我我做错了
答案 0 :(得分:0)
将最后一行移到第一行实际上是您错误地覆盖了Laravel路线:
Route::resource('quotation', 'QuotationController');
Route::group(['prefix' => 'quotations'], function () { // Here I changed
Route::get('data', 'QuotationController@data');
Route::post('send_quotation', 'QuotationController@sendQuotation');
Route::get('{quotation}/show', 'QuotationController@show');
Route::get('{quotation}/edit', 'QuotationController@edit');
Route::get('{quotation}/delete', 'QuotationController@delete');
Route::get('{quotation}/ajax_create_pdf', 'QuotationController@ajaxCreatePdf');
Route::get('{quotation}/print_quot', 'QuotationController@printQuot');
Route::get('{quotation}/make_invoice', 'QuotationController@makeInvoice');
Route::get('{quotation}/approve', 'QuotationController@approve');
Route::get('{quotation}/confirm_sales_order', 'QuotationController@confirmSalesOrder');
Route::put('{quotation}', 'QuotationController@update');
Route::delete('{quotation}', 'QuotationController@destroy');
Route::get('ajax_qtemplates_products/{qtemplate}', 'QuotationController@ajaxQtemplatesProducts');
Route::get('ajax_sales_team_list', 'QuotationController@ajaxSalesTeamList');
Route::get('draft_quotations_list/data', 'QuotationController@draftQuotations');
Route::get('draft_quotations', 'QuotationController@draftIndex');
});
实际上,Laravel的资源方法会自动创建默认网址。查看Laravel resource了解更多信息。
祝你好运!
答案 1 :(得分:0)
它中断了,因为您已经定义了路由,并在添加之后:Route::resource('quotation', 'QuotationController');
我建议保留Route::resource
!密切关注Laravel Routing Docs
答案 2 :(得分:-1)
像这样使用它:
Route::get('{quotation}/{id}/edit', 'QuotationController@edit');
此外,如果尚未传递参数($id)
,则在控制器中传递它。