Support the ongoing development of Laravel.io →
posted 10 years ago
Blade
Last updated 2 years ago.
0

Is there a column named 'id in your posts table ?

Do a dd( $posts->toArray() ) and check id exists.

Last updated 2 years ago.
0

Yes, there is.

In fact the code below also works:

$posts->first()->id
Last updated 2 years ago.
0

$posts->toArray() gives the following error:

ErrorException Call to undefined method Illuminate\Database\Query\Builder::toArray()

Last updated 2 years ago.
0
Solution

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())

Last updated 2 years ago.
0

It was $posts = Post::where('jeornal_id', '=', $jeornal->id)

I added get(), and it is ok :) Thank you very much.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mehmet mehmet Joined 18 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.