Then it's going to pull the first record from that array where periodo_id = 2. As there's only one record, and the periodo_id = 2, it's just going to return that single record:
{"metaMensal":"139747.6600","periodo_id":2}
Eduardo Fuerte
ASKER
Hi Chris
Sorry!
Your reply is perfectly correct and solved my issue.
My last post wasn't complete before I sent it.
I was just thinking about the 1st query, without ->get() produces an object where I could apply the 2nd query and inadvertently sent it.
When you're dealing with Eloquent, you're dealing with a QueryBuilder. This means that you can keep on adding methods to adjust the query (where(), limit(), etc). You carry on with a QueryBuilder instance until you call the get() method, or one of the other equivalents (first() etc) - at this point, the QueryBuilder sends the actualy SQL query to the Database and the results are returned. Once you've sent the query, you no longer have the QueryBuilder so you can't then add more methods to it, which is why we add to it before calling get().
Think of the QueryBuilder as a way to prepare your query, and the get() method etc as a way to send the query.
So did I
That results in:
Open in new window