我试图使用steamid作为我的路线,所以它将是www.example.com./profile/76561198050605019
我现在的代码是:
Route::get('{steamid}', function($steamid){
$user = App\user::find($steamid);
echo 'hello my steam name is ' . $user->username . '<br />';
echo 'hello my steam ID64 is ' . $user->steamid . '<br />';
});
我有,那应该有效但不是。 我试过这个并且有效:
Route::get('{steamid}', function($id){
$user = App\user::find($id);
echo 'hello my steam name is ' . $user->username . '<br />';
});
使用www.example.com/profile/3的网址
EDIT ::
我修复了自己的问题
$user = User::where('steamid', $steamid)->firstOrFail();
我需要使用那条线。
答案 0 :(得分:0)
要解决此问题,您需要更改此
$user = App\user::find($steamid);
此
$user = App\user::where('steamid', $steamid)->firstOrFail();