I am using Laravel 5.2. I am looking querying usernames with eloquent in order to create a unique profile page. The issue I am having is the usernames are returning with white space e.g. John Doe I need it to return with no white space like johndoe or JohnDoe. Thanks.
public function show($username)
{
try
{
$user = str_replace(' ', '', User::wherename($username)->firstOrFail());
dd($user);
}
catch(ModelNotFoundException $e)
{
return redirect()->action('HomeController@index');
}
}