0

客户有很多账户,账户有很多交易。

我想从一位客户那里获得所有交易..?

$customer = Auth::user();
$statement = $customers->accounts()->transactions()->where('customer_no', '=',     $customer->customer_no)->get(); //get all transactions

我知道这不起作用,但这是我能得到的最接近的..

4

1 回答 1

2
$customer = Auth::user();
$account_ids = $customers->accounts()->lists('id');
$statement = Transaction::where_in('account_id', $account_ids)->where('customer_no', '=', $customer->customer_no)->get(); // Get all transactions

您可能不需要“customer_no”部分 b/c

于 2013-03-13T22:34:29.310 回答