<?php

namespace App\Models;

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

    protected $allowedFields = [
        'membership_id',
        'benefit_description',
        'used_at',
        'pos_order_id',
    ];

    public function forMembership(int $membershipId): array
    {
        return $this->where('membership_id', $membershipId)->orderBy('used_at', 'desc')->findAll();
    }
}
