我正在创建商业网站。我的网站包含帖子广告表单。该表单包含广告类型字段。有3种类型:豪华版,高级版,普通版。我使用广告表单发布了10条记录。现在,我希望按照广告类型的顺序列出我的广告数据 - 豪华(5天明智),高级(5天明智)....),所有常规(明天)
答案 0 :(得分:0)
只需根据需要多次调用orderBy()
即可。例如:
User::orderBy('type', 'DESC')
->orderBy('date', 'ASC')
->get();
答案 1 :(得分:0)
$ads = Advertisement::where('ad_status',1)
->orderByRaw('case
when ads_type LIKE "%Deluxe%" then 1
when ads_type LIKE "%Premium%" then 2
when ads_type LIKE "%Regular%" then 3
end')->get();