I have 3 Models "Category", "Post", and "User". A Category has a hasMany relationship with Post. And a Post has a belongsTo relationship with User.
I have a Category object $cat1
and i can access its posts (and the user_id) in my view, but i can't access more user data (line name)
@foreach ($cat1->posts as $post)
{{ $post->title }}
{{ $post->user()->name }}
@endforeach
This throws an error
Undefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$name