Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel 6 use username instead of id

// using User->username instead of id on url:
public function show($user)
    {
  		// where<YourAtributeName>($param)->firstOrFail()
        $user = User::whereUsername($user)->firstOrFail();
        return view('users.show', ['user'=>$user]);
    }
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #laravel #username #id
ADD COMMENT
Topic
Name
1+5 =