0

Im trying to use steamid as my route so it will be www.example.com./profile/76561198050605019

The code i have right now is:

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 />';
});

I have that and that should work but its not. I have tryed this and it works:

Route::get('{steamid}', function($id){
    $user = App\user::find($id);
    echo 'hello my steam name is ' . $user->username . '<br />';
});

With the url of www.example.com/profile/3

EDIT::

I have fixed my own problem

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

I need to use that line.

Skel
  • 1,611
  • 3
  • 16
  • 36

1 Answers1

0

To fix the problem you need to change this

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

This

$user = App\user::where('steamid', $steamid)->firstOrFail();
Skel
  • 1,611
  • 3
  • 16
  • 36