mercredi 30 novembre 2016

Detect duplicate variable with Laravel Collections

I have this collections of cart ecommerce items, I want detect that items have the same article_id value:

Collection {#306 ▼
  #items: array:3 [▼
    0 => CartLine {#294 ▼
      +cart_line_id: 836473
      +cart_id: 12957798
      +parent_line_id: null
      +quantity: 2
      +article_id: 1728
      +article_name: "TAZA CERAMICA"
      +data: ""
      +extradata: "{"original_dsn":"qF3Xxttr3B2w","tmp_dsn":"tmp_4k0k9q6usqd7pnu7d70rg0ta674zv8v4"}"
      +article_family_id: "AAAPTP"
      +article_on_line_v: 1
      +promotion_code: null
      +promotion_id: null
      +url_preview: "http://ift.tt/2fKxNsM"
      +available_modify: true
      +model: ArticleModel {#295 ▶}
      +cession: 5.34
      +cession_original: 5.34
      +pvp: 9.95
      +pvp_original: 9.95
      +pvp_discount: 0.0
      +cession_discount: 0.0
      +discount_regularization: null
      +total_cession: 10.69
      +total_cession_original: 10.68
      +total_pvp: 19.9
      +total_pvp_original: 19.9
      #_READ_ONLY: []
      #_HIDDEN_FIELDS: []
      +__WARNINGS: []
    }
    1 => CartLine {#296 ▼
      +cart_line_id: 836474
      +cart_id: 12957798
      +parent_line_id: null
      +quantity: 1
      +article_id: 1728
      +article_name: "TAZA CERAMICA"
      +data: ""
      +extradata: "{"original_dsn":"59avc306wjem","tmp_dsn":"tmp_vnr16irux3ebi6pwy0dmn7ypeqwnr376"}"
      +article_family_id: "AAAPTP"
      +article_on_line_v: 1
      +promotion_code: null
      +promotion_id: null
      +url_preview: "http://ift.tt/2gEOfzx"
      +available_modify: true
      +model: ArticleModel {#297 ▶}
      +cession: 5.34
      +cession_original: 5.34
      +pvp: 9.95
      +pvp_original: 9.95
      +pvp_discount: 0.0
      +cession_discount: 0.0
      +discount_regularization: null
      +total_cession: 5.34
      +total_cession_original: 5.34
      +total_pvp: 9.95
      +total_pvp_original: 9.95
      #_READ_ONLY: []
      #_HIDDEN_FIELDS: []
      +__WARNINGS: []
    }
    2 => CartLine {#298 ▼
      +cart_line_id: 836475
      +cart_id: 12957798
      +parent_line_id: null
      +quantity: 1
      +article_id: 1378
      +article_name: "JARRA CERVEZA ALEMANA"
      +data: ""
      +extradata: "{"original_dsn":"null","tmp_dsn":"tmp_8cu2ls6q18ip6vvd7qccrsbjiebgsrzj"}"
      +article_family_id: "AAAPTP"
      +article_on_line_v: 1
      +promotion_code: null
      +promotion_id: null
      +url_preview: "http://ift.tt/2fKxtdR"
      +available_modify: true
      +model: ArticleModel {#299 ▶}
      +cession: 10.21
      +cession_original: 10.21
      +pvp: 19.0
      +pvp_original: 19.0
      +pvp_discount: 0.0
      +cession_discount: 0.0
      +discount_regularization: null
      +total_cession: 10.21
      +total_cession_original: 10.21
      +total_pvp: 19.0
      +total_pvp_original: 19.0
      #_READ_ONLY: []
      #_HIDDEN_FIELDS: []
      +__WARNINGS: []
    }
  ]
}

In this case, there are two items with same article_id value, 1728. I want get only the two items with this article_id.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2g5kQee
via IFTTT

Aucun commentaire:

Enregistrer un commentaire