mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-09-01 02:43:58 +00:00
conditionally load wallet in company resource
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithWallets implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('wallets');
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()) : [],
|
||||
|
||||
Reference in New Issue
Block a user