Edit File: OrderDetailsResource.php
<?php namespace App\Http\Resources\Api\Provider; use Carbon\Carbon; use App\Models\Provider; use App\Enums\OrderStatusEnum; use Illuminate\Http\Resources\Json\JsonResource; use App\Http\Resources\Api\User\Basics\BasicUserResource; use App\Http\Resources\Api\User\Basics\BasicDelegateResource; use App\Http\Resources\Api\General\Settings\CancelReasonResource; class OrderDetailsResource extends JsonResource { public function toArray($request) { return [ 'id' => $this?->id, 'order_number' => $this?->order_num, 'receiving_method' => $this->receiving_method, 'status' => $this?->status, 'order_call_type' => 'order', 'notes' => $this?->notes, 'room_id' => $this?->room?->id, // When Order is Scheduled 'schedule_execution_date' => $this?->schedule_execution_date, 'schedule_execution_time' => $this?->schedule_execution_time, // 'room_id' => $this?->room_id, 'order_info' => [ 'status' => $this?->status, 'receiving_method' => $this->receiving_method, // When Order is Scheduled 'schedule_execution_date' => $this?->schedule_execution_date, 'schedule_execution_time' => $this?->schedule_execution_time, 'order_type' => [ 'slug' => $this?->order_type, 'text' => $this?->order_type_text, ], // When Receiving in Store 'car_color' => $this?->car_color, 'car_model' => $this?->car_model, 'car_plat_number' => $this?->car_plat_number, 'notes' => $this?->notes, 'receiving_in_store_notes' => $this?->receiving_in_store_notes, 'created_at' => $this->created_at->translatedFormat('j F Y'), 'created_at_time' => Carbon::parse($this->created_at)->isoFormat('h:mm A'), ], // Financial Transactions 'financial_transactions' => [ 'coupon_num' => $this?->coupon_num, 'coupon_type' => $this?->coupon_type, 'coupon_value' => $this?->coupon_value, 'vat_per' => $this?->vat_per, 'vat_amount' => $this?->vat_amount, 'coupon_amount' => $this?->coupon_amount, 'total_products' => $this?->total_products, 'delivery_price' => $this?->delivery_price, 'final_total' => $this?->final_total, 'pay_type' => $this?->pay_type, 'pay_type_text' => $this?->pay_type_text, 'pay_status' => $this?->pay_status, ], 'is_delegate_rated' => $this->when( isset($this?->delegate_id), $this->delegate?->givenRates()->whereOrderId($this->id) ->where(['ratingable_type' => Provider::class, 'ratingable_id' => auth()->id()])->exists() ?? false ), // Informations 'user' => BasicUserResource::make($this?->user), 'delegate' => BasicDelegateResource::make($this?->delegate), // Address Details 'lat' => $this?->lat, 'lng' => $this?->lng, 'map_desc' => $this?->map_desc, // Order Items 'order_items' => OrdersItemResource::collection($this?->orderItems), // When Cancelling 'cancellation_reason' => (is_null($this?->cancellationReason) && $this->status['value'] == OrderStatusEnum::Cancelled->value) ? [ 'id' => 0, 'reason' => __('apis.cancel_because_proider_dont_respond') ] : CancelReasonResource::make($this?->cancellationReason), 'live_call' => [ 'api_key' => $this->api_key, 'session_id' => $this->session_id, 'token' => $this->token, 'secret_key' => $this->secret_key, ], 'currency' => __('site.currency'), ]; } }
Back to File Manager