<?php


namespace API\User\Http\Resources;


use API\Product\Http\Resources\ProductResource;
use API\Service\Http\Resources\ServiceResource;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;


class ServiceOrderResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {



        return [
            "price"=>$this->price == 0 ? 'توافقی' : format_price_with_currencySymbol($this->price),
            "status"=>$this->status,
            "persian_status"=>$this->getStatusForShowUsers(),
            "id"=>$this->id,
            "code"=>$this->code,
            "service"=>new ServiceResource($this->service),
            "created_at"=>$this->created_at,
            "can_pay"=>$this->status == \Mehrab\OrderService\Models\OrderService::WAITING_PAYMENT,
            "can_see_factor"=>in_array($this->status,[\Mehrab\OrderService\Models\OrderService::DONE,\Mehrab\OrderService\Models\OrderService::DONE_AND_WAITING_FEEDBACK_FOR_EXPERT]),
            "can_cancel"=>$this->getCanUserCancelOrder(),
            "can_send_feedback"=>$this->status == \Mehrab\OrderService\Models\OrderService::DONE_AND_WAITING_FEEDBACK_FOR_EXPERT,
        ];
    }
}
