<?php

namespace App\Models;

use CodeIgniter\Model;

class SpinRewardModel extends Model
{
    protected $table = 'spin_rewards';
    protected $primaryKey = 'id';
    protected $allowedFields = ['msisdn', 'points', 'spin_date', 'created_at', 'claimed_at'];
    protected $useTimestamps = false;

    public function hasClaimedToday(string $msisdn, string $spinDate): bool
    {
        return (bool) $this->where('msisdn', $msisdn)
            ->where('spin_date', $spinDate)
            ->where('claimed_at IS NOT NULL', null, false)
            ->first();
    }
}
