mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
conditionally load wallet in company resource
This commit is contained in:
@@ -61,7 +61,7 @@ class CompanyResource extends JsonResource
|
||||
],
|
||||
'segments' => SegmentResource::collection($this->segments),
|
||||
'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()),
|
||||
'wallet' => $this->whenLoaded('wallets', new WalletResource($this->wallets()->first()), ''),
|
||||
'wallet' => $this->whenLoaded('wallets', new WalletResource($this->wallets()->with('transactions')->first()), new WalletResource($this->wallets()->first())),
|
||||
'created_at' => $this->created_at->format('d-m-Y'),
|
||||
$this->mergeWhen($this->business_type === BusinessType::CURRENCY_VENDOR, [
|
||||
'currencies' => $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : [],
|
||||
|
||||
@@ -21,8 +21,8 @@ class WalletResource extends JsonResource
|
||||
'currency_id' => $this->currency_id,
|
||||
'amount' => (double) $this->amount,
|
||||
'company_id' => (int) $this->owner->id,
|
||||
'transactions' => WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()),
|
||||
'top_up_records' => WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get())
|
||||
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()), []),
|
||||
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get()), []),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user