<?php

namespace App\Http\Resources\Api\Dashboard\Admin\Coupon;

use Illuminate\Http\Resources\Json\JsonResource;

class CouponResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'id'                            => (int) $this->id,
            'code'                          => (string) $this->code,
            'is_active'                     => (bool) $this->is_active,
            'start_date'                    => $this->start_date,
            'start_time'                    => $this->start_time,
            'end_date'                      => $this->end_date,
            'end_time'                      => $this->end_time,
            'amount'                        => $this->amount,
            'amount_type'                   => $this->amount_type,
            'max_discount_value'            => (double) $this->max_discount_value,
            'number_of_times_used_for_user' => (int) $this->number_of_times_used_for_user,
            'number_of_times_used'          => (int) $this->number_of_times_used,
            'max_number_of_users'           => (int) $this->max_number_of_users,
            'users_used_count'              => (int) $this->users_used_count,
            'created_at'                    => $this->created_at->format('Y-m-d'),
        ];
    }
}
