samedi 4 février 2017

how to display photo from a relationship in laravel

I have this relationships

User.php

 // a user has only one user detail 
    public function userdetail()
    {
        return $this->hasOne('App\UserDetail');
    }

UserDetail.php

 public function user(){
            return $this->belongsTo('App\User');
        }

in my controller

    $userprofile = User::find(Auth::id())->with('detail')->first(); 
   return view('admin.index', compact('users', 'administrators', 'messages','userprofile'));

but when I display it in the header.

  <a href="#" class="dropdown-toggle pr-0" data-toggle="dropdown"><img src="{!! url('/uploads/thumbs' , $userprofile->file_name) !!}" alt="user_auth" class="user-auth-img img-circle"/><span class="user-online-status"></span></a>

I can't see my photo. Can you also give me some snippet of code that if there's no uploaded picture. I display a default profile picture



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jQeqAQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire