我有以下表格结构; 订单:
id, user_id, from_time, to_time, product_id, quantity, price, created_at, updated_at
所以说我有3个订单,包含以下数据:
user_id: 1,
from_time: 10:00,
to_time: 11:00
user_id: 2,
from_time: 12:00,
to_time: 15:00
user_id: 3,
from_time: 11:00,
to_time: 12:00
我的目标是获取所有订单并对其进行排列,以便from_time
和to_time
也在ascending order
中,在我的情况下,订单将为1, 3, 2.
答案 0 :(得分:2)
使用orderBy()
查询方法?
Foo::orderBy('from_time', 'asc')->orderBy('to_time', 'asc');