diff --git a/app/Classes/General/Eloquent/Filters/WithWallets.php b/app/Classes/General/Eloquent/Filters/WithWallets.php new file mode 100644 index 00000000..5b002922 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithWallets.php @@ -0,0 +1,20 @@ +with('wallets'); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyLogic.php b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyLogic.php index 5406d682..3c3fb088 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyLogic.php @@ -52,10 +52,10 @@ class FetchCompanyLogic extends AbstractControllerLogic { $this->canFetchCompany->passes(); - $query = $this->fetchesCompany->execute(['id' => $request->route('id'), 'with_bookings' => true]); + $query = $this->fetchesCompany->execute(['id' => $request->route('id'), 'with_bookings' => true, 'with_wallets' => true]); return $this->resourceResponse(new CompanyResource($query)); } -} \ No newline at end of file +} diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index ab750406..7d116db6 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -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, diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index fceab5bc..7070b87f 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -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()) : [],