Is there a column named 'id
in your posts table ?
Do a dd( $posts->toArray() )
and check id exists.
Yes, there is.
In fact the code below also works:
$posts->first()->id
$posts->toArray() gives the following error:
ErrorException Call to undefined method Illuminate\Database\Query\Builder::toArray()
What's the query that produces $posts? That error typically means a ->get() is missing from the end of the Eloquent query (or an alternative to get())
It was $posts = Post::where('jeornal_id', '=', $jeornal->id)
I added get(), and it is ok :) Thank you very much.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community