<?php

namespace App\Models;

class LoyaltyTransactionModel extends TenantModel
{
    protected $table         = 'loyalty_transactions';
    protected $primaryKey    = 'id';
    protected $returnType    = 'object';
    protected $useTimestamps = true;
    protected $createdField  = 'created_at';
    protected $updatedField  = '';

    protected $allowedFields = [
        'guest_id',
        'type',
        'points',
        'reference_type',
        'reference_id',
        'notes',
        'created_by',
    ];

    public function forGuest(int $guestId): array
    {
        return $this->where('guest_id', $guestId)->orderBy('created_at', 'desc')->findAll();
    }
}
