vendredi 17 mai 2019

Laravel collection: flatten method ignored

Possibly an obvious one, but here it is: After dd'ing a query result, I have:

$items = DB::table('my_table')->get(['id']);
dd($items);

Which results in:

Collection {#228 ▼
  #items: array:1 [▼
    0 => {#227 ▼
      +"id": 2
    }
  ]
}

Then, when I try to flatten it, it ignores me:

dd($items->flatten());

Resulting in:

Collection {#209 ▼
  #items: array:1 [▼
    0 => {#227 ▼
      +"id": 2
    }
  ]
}

Shouldn't I receive something like the flattened version of the collection? How can I do it?

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire