<?php

namespace App\Http\Resources\Discounts;

use Illuminate\Http\Resources\Json\JsonResource;

class DiscountParentResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => $this['id'] ?? null,
            'firstname' => $this['firstname'] ?? '',
            'lastname' => $this['lastname'] ?? '',
            'email' => $this['email'] ?? '',
            'total_discount' => (float) ($this['total_discount'] ?? 0),
            'has_discount' => (int) ($this['has_discount'] ?? 0),
        ];
    }
}
