Answer the question
In order to leave comments, you need to log in
Why can't I access the 'image' property in $user->book->image?
Hello. I don't understand why I can't access the image property:
{{ $user->book['image'] }} // дает результат
{{ $user->book->image }} // не работает и выдает исключение:
//<i>"Trying to get property 'image' of non-object"</i>
public function book()
{
return $this->belongsTo(Book::class);
}
public function users()
{
return $this->hasMany(User::class);
}
Answer the question
In order to leave comments, you need to log in
Image is a column in the books table? Please dump $user->book
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question