【问题标题】:Steam Auth $steamid not able to use in routes in laravelSteam Auth $steamid 无法在 laravel 的路线中使用
【发布时间】:2015-11-20 12:47:37
【问题描述】:

我尝试使用 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 的网址

编辑::

我已经解决了我自己的问题

$user = User::where('steamid', $steamid)->firstOrFail();

我需要使用那条线。

【问题讨论】:

  • 什么不工作,什么错误?
  • 嗯,错误是带有蒸汽 id 的 url 不起作用。但我现在知道为什么它不起作用并且我已经修复了它
  • 您能否也发布您的解决方案作为答案并接受它,以便其他人可以清楚地看到解决方案是什么?
  • 是的,对不起,我是堆栈新手

标签: php laravel steam steam-web-api steamworks-api


【解决方案1】:

要解决这个问题,你需要改变这个

$user = App\user::find($steamid);

这个

$user = App\user::where('steamid', $steamid)->firstOrFail();

【讨论】:

    猜你喜欢
    • 2012-10-20
    • 1970-01-01
    • 2021-02-23
    • 1970-01-01
    • 2016-09-16
    • 2021-04-14
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    相关资源
    最近更新 更多