vendredi 26 avril 2019

union a collection with missing values laravel

i am trying to add missing values to a collection that results my database table containing multiple items.

What i am trying to attempt is to add the items that are missing from collection as union values.

Collection {#217 ▼

 #items: array:7 [▼

0 => {#397 ▼

  +"item_id": 1

  +"amount": "4"

}

1 => {#402 ▼

  +"item_id": 3

  +"amount": "1"

}

2 => {#396 ▶}

3 => {#213 ▶}

4 => {#399 ▶}

5 => {#400 ▶}

6 => {#398 ▶}

]

}

i used union but it's not working,it makes a spererate array

$union = $collection->union([2 => ['0']]);

i don't want separate arrays and repeating items.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ZCyPzt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire