我想根据 customer_id 一列选择行。现在的情况是 Invoices 表中有一个 ccustomer_id 列。
这是我现在得到它的方式
Invoice::where('payment_status',1)->get()
但是这个查询的问题是如果客户有两张发票,它将同时获得两张发票。我只需要最新的?
那个东西会被查询什么?
答案 0 :(得分:2)
这是你需要做的
Invoice::where('payment_status',1)->order_by('created_at', 'desc')->first();