简体   繁体   中英

How to get last 7 days records from database by special raw

I'm using Laravel and that's my issue

I need to get last 7 days records from table Orders by special raw 'location_name'.

$name = \App\Order::whereBetween('working_time',[Carbon::today()->startOfWeek(),Carbon::today()->endOfWeek()])->get();

this code return last 7 days but I need to order by 'location_name'

尝试这个:

$name = \App\Order::whereBetween('working_time',[Carbon::today()->startOfWeek(),Carbon::today()->endOfWeek()])->orderBy('location_name')->get()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM