conditionally load wallet in company resource

This commit is contained in:
Omair Saleh
2022-09-30 04:20:49 +08:00
parent e45d9c8420
commit 6ad167f73e
4 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class BookingResource extends JsonResource
{
return [
'id' => $this->id,
// 'company' => new CompanyResource($this->company),
'company' => new CompanyResource($this->company),
'bank' => new BankResource($this->bank),
'service' => new ServiceTypeResource($this->service),
'marking' => $this->marking,
+1 -1
View File
@@ -61,7 +61,7 @@ class CompanyResource extends JsonResource
],
'segments' => SegmentResource::collection($this->segments),
'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()),
'wallet' => new WalletResource($this->wallets()->first()),
'wallet' => $this->whenLoaded('wallets', 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()) : [],