$this->id, 'name' => $this->name, 'time_limit' => $this->when($this->whereHas('constants', function($query){ $query->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT); }), $this->constants->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT)->first()), 'services' => CustomServiceTypeResource::collection($this->constants->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)) ]; } }