<?php

namespace App\Http\Resources;

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

class LoyaltyTransactionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'customer_id' => $this->customer_id,
            'type' => $this->type,
            'points' => $this->points,
            'balance_after' => $this->balance_after,
            'notes' => $this->notes,
            'created_at' => $this->created_at,
            'user' => $this->whenLoaded('user', fn () => $this->user?->only(['id', 'name'])),
        ];
    }
}
