Reputation: 1058
@if(Auth::check() && isset(Auth::user()->image))
<img src="{{asset('storage/app/profile/'.Auth::user()->image)}}" class="img-circle" alt="User Image">
@endif
its generating storage/app/profile/[]
using laravel 5.3 with mongodb
user model>>>
am having this model where image is also used in api
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'coordinates', 'kids','partener_name','partner_age','age','about_us','dogs','intrests'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
protected $with=['image'];
public function image(){
return $this->hasMany('App\Models\Api\UserImage')->orderBy('serial','ASC');
}
}
Upvotes: 1
Views: 161
Reputation: 163768
You said Auth::user()->image
is a collection. This means user has multiple images, so you need to iterate over them. For example:
@if(Auth::check() && isset(Auth::user()->image))
@foreach (Auth::user()->image as $image)
<img src="{{asset('storage/app/profile/'.$image->url)}}" class="img-circle" alt="User Image">
@endforeach
@endif
If that's not what you want and you just one to have one image per user, check your User
model. It seems you have image()
relation which should be removed or renamed.
Upvotes: 2