<?php

namespace Modules\SpecialAttendance\Transformers;

use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

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

        return [
            'id' => $this->id,
            'deduction_type' => $this->deduction_type,
            'purpose' => $this->purpose,
            'amount' => $this->amount,
            'days' => $this->days,
            'is_applicable' => $this->is_applicable ? _trans('common.Yes') : _trans('common.No'),
            'considered_by' => @$this->consideredBy->name ?? null,
            'considered_at' => $this->considered_at ? Carbon::parse($this->considered_at)->format('Y-m-d h:i A') : null,
        ];
    }
}
