dimanche 3 décembre 2017

Display user profile url by name instead of ID

I am Newbie. I'm trying to return a view of member profile

At the moment, the user profile is accessible by its ID, like so

profile/7

I would like to access it through the name that I've created

profile/John

this is my route

Route::get('profile/{id}', 'ProfilController@tampilkanID');

this is my controller

public function tampilkanID($id)
{
    $auth = Auth::user()->id;
    $users=\App\users::all()->whereNotIn('id',$auth);
    $tampilkan = Users::find($id);
    return view('tampilkan', compact('tampilkan', 'users')); 
}

and this how i call it in my blade

 @foreach($users as $user)
           <tr>
               <td><a id="teamname" href="" target="_blank"></a></td>
              </tr>
 @endforeach

thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire