imhitt
1 week ago
504
21
Laravel

Laravel Eloquent “with” / “load” return null

Posted 1 week ago by imhitt

I am trying to get ralation (product owner) using with method but it returns me null.

My User model:

public function goods()
{
    return $this->hasMany(Good::class);
}

My Good model:

public function user()
{
    return $this->belongsTo(User::class);
}

Problem in real example:

View file: https://i.stack.imgur.com/M9V7V.png

Output: https://i.stack.imgur.com/jIKtH.png

Why i can not get relation with with of load method ?

*same questionon stackoverflow https://stackoverflow.com/questions/61916987/laravel-eloquent-with-load-return-null

Please sign in or create an account to participate in this conversation.