Answer the question
In order to leave comments, you need to log in
Laravel when accessing a property Trying to get property of non-object?
The Pix model has a link to the Picture model
public function picture()
{
return $this->hasMany(Picture::class, 'pix_id');
}
public function pix()
{
return $this->belongsTo(Pix::class);
}
Answer the question
In order to leave comments, you need to log in
Notice dd on dump and you will see on which iteration of the loop the error occurs and, therefore, which model has no pictures.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question