<?php

namespace App\Http\Resources;

use App\Http\Resources\PosStaffResource;
use Illuminate\Http\Resources\Json\JsonResource;

class SaleDetailResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'uuid' => $this->uuid,
            'tracking' => $this->tracking,
            'items' => $this->items,
            'cart_total_price' => $this->cart_total_price,
            'cart_total_cost' => $this->cart_total_cost,
            'payable_after_all' => $this->payable_after_all,
            'discount_rate' => $this->discount_rate,
            'is_discount_in_percentage' => $this->is_discount_in_percentage,
            'discount_amount' => $this->discount_amount,
            'staff_note' => $this->staff_note,
            'payment_note' => $this->payment_note,
            'tax' => $this->tax,
            'profit_after_all' => $this->profit_after_all,
            'tax_amount' => $this->tax_amount,
            'chef' => new PosStaffResource($this->chef),
            'biller' => new PosStaffResource($this->biller),
            'taker' => new PosStaffResource($this->taker),
            'customer' => new PosCustomerResource($this->customer),
            'table' => new PosServiceTableResource($this->serviceTable),
            'took_at' => $this->took_at,
            'is_preparing' => $this->is_preparing,
            'progress' => $this->progress,
            'is_cancelled' => $this->is_cancelled,
            'cancellation_reason' => $this->cancellation_reason,
            'completed_at' => $this->completed_at,
            'tip_amount' => $this->tip_amount,
            'is_paid' => $this->is_paid,
            'payment_method_id' => $this->payment_method_id,
            'created_at' => $this->updated_at->format(config('app.app_date_format')),
            'updated_at' => $this->updated_at->format(config('app.app_date_format')),
        ];
    }
}
