Orm Merge Collection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1498

    Orm Merge Collection

    Hi,
    it's possible to merge collection like :


    PHP Code:
    //two model has exactly same column
    $asia_best_seller = App/AsiaSeller::select("name", "sales_volume", "birth_day", "on_board_day")
       ->orderBy("sales_volume", "desc")
       ->take(10)
       ->get();
    $euro_best_seller = App/AsiaSeller::select("name", "sales_volume", "birth_day", "on_board_day")
       ->orderBy("sales_volume", "desc")
       ->take(10)
       ->get();
    
    $asia_best_seller->merge($euro_best_seller);
    //you will get only one collect !!​​ 
    
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • yuri
    Member
    • Mar 2014
    • 8627

    #2
    I've never needed that when developing for Espo. You can always cast to array.

    PHP Code:
            $collection = new EntityCollection([
                ...iterator_to_array($collection1),
                ...iterator_to_array($collection2),
            ]);
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...