$this->id, 'code' => $this->code, 'currency_id' => $this->currency_id, 'amount' => (double) $this->amount, 'company_id' => (int) $this->owner->id, 'transactions' => $this->transactions()->orderBy('id', 'DESC')->get(), 'topup_transactions' => $this->transactions()->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get(), // 'transaction' => $this->whenLoaded('transactions', function() { // return [ // 'topup' => $this->transactions // ]; // }), // 'transaction' // all // 'top_transaction' // only topup ]; } }