<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class ReportResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'                       => $this->id,
            'code'                     => $this->code,
            'report_date'              => $this->report_date,
            'customer_id'              => $this->customer_id,
            'charge_id'                => $this->charge_id,
            'primary_member'           => $this->primary_member,
            'second_member'            => $this->second_member,
            'car'                      => $this->car,
            'notice'                   => $this->notice,
            'request'                  => $this->request,
            'on_site_cost'             => $this->on_site_cost,
            'estimated_workload'       => $this->estimated_workload,
            'has_estimated'            => $this->has_estimated,
            'is_finished'              => $this->is_finished,
            'user_id'                  => $this->user_id,
            'leader_id'                => $this->leader_id,
            'reporter_id'              => $this->reporter_id,
            'progressing_user_id'      => $this->progressing_user_id,
            'report_created_at'        => $this->report_created_at,
            'is_allowed_single_report' => $this->is_allowed_single_report,
            'is_record'                => $this->is_record,
            'detail'                   => $this->detail,
            'is_new'                   => $this->is_new,
            'is_activated'             => $this->is_activated,
            'created_at'               => isset($this->created_at) ? date('Y-m-d H:i:s', strtotime($this->created_at)) : null,
            'updated_at'               => isset($this->created_at) ? date('Y-m-d H:i:s', strtotime($this->created_at)) : null,
        ];
    }
}
