Laravel NotFoundHttpException

风格不统一 提交于 2019-12-23 12:16:19

问题


I have a problem with this one route.

Route::get('va/{$uniqueid}','AdminController@VaShow')->name('va');

and in controller:

  public function VaShow($uniqueid = '123'){
      dd($uniqueid);
    }

but i still get NotFoundHttpException when trying to visit route. (it have admin prefix but anyway i'm trying to access it directly with url and in view but still same) in view:

{{route('va',['uniqueid'=>$v->uniqueid])}}

and I checked in route:list, its there:

|        | GET|HEAD | admin/va/{$uniqueid}     | va                 | App\Http\Controllers\AdminControl
ler@VaShow               | web,admin    |

No idea what I did wrong


回答1:


The dollar sign in your route is throwing it off. The variables in the route do not need a dollar sign:

Route::get('va/{uniqueid}','AdminController@VaShow')->name('va');



回答2:


Try to Remove $ symbol.

Route::get('va/{uniqueid}','AdminController@VaShow')->name('va');



回答3:


You don´t need the dollar sign. You could add ? at the end of the parameter in case the parameter is optional to send.

Route::get('va/{uniqueid?}','AdminController@VaShow')->name('va');


来源:https://stackoverflow.com/questions/42166020/laravel-notfoundhttpexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!