Laravel - Get the last entry of each UID type

后端 未结 6 1995
栀梦
栀梦 2020-11-30 15:46

I have a table that has 100\'s of entries for over 1000 different products, each identified by a unique UID.

ID  UID                 MANY COLUMNS    CREATED          


        
6条回答
  •  -上瘾入骨i
    2020-11-30 16:32

    You can achieve this with eloquent using orderBy() and groupBy():

    $data = TblModel::orderBy('id','DESC')->groupBy('uid')->get();
    

提交回复
热议问题