Stephany. S123
Stephany. S123

Reputation: 17

Laravel show username instead of id on edit profile

When the user has to edit their profile it shows the id like so Click to see the photo

that is not what I want. I want to replace it with the profile username and remove the edit part. I really hope someone is understanding what I'm asking for. let me show you what I am looking for something like this "localhost/lary/quickstart/public/profile/username"

here is what i have in my code

public function edit($id)
{

      $pro=Profile::find($id);
      return view('layouts.profileedit')->with('pro',$pro);


}

<a href="{{route('profile.edit',$use->id)}}" style="color:#F88B22;"><span class="glyphicon glyphicon-pencil"></span></a> 

Upvotes: 0

Views: 454

Answers (1)

Paras
Paras

Reputation: 9465

Change your routes file as follows:

Route::resource('profile', 'ProfileController', ['except' => ['edit']]);
Route::get('/profile/{username}', 'ProfileController@edit');

Then change your ProfileController as follows

public function edit($username)
{
      $pro=Profile::where('username', $username)->firstOrFail();
      return view('layouts.profileedit')->with('pro',$pro);
}

Upvotes: 1

Related Questions