It's most like that you are using the hasMany
relationship in your User model. When using the hasMany
relationship, it will return a Collection
object, rather than your model itself. Take a look at the API for the Collection object and you'll find many helpful methods.
What you should probably do is something like this.
foreach ($user->photo->all() as $photo)
{
echo $photo;
}
Or, if your user only has one photo, then change your relationship in the User model to hasOne
. Then you can use it as you are now.
echo $user->photo;