<?php

namespace App\Models;

use CodeIgniter\Model;

class ViolationSanctionModel extends Model
{
    protected $table            = 'violation_sanctions';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $allowedFields    = ['min_points', 'action_title', 'description'];
    protected $useTimestamps    = true;

    // Ambil sanksi terberat yang dicapai berdasarkan jumlah poin
    public function getActiveSanction($points)
    {
        return $this->where('min_points <=', $points)
            ->orderBy('min_points', 'DESC')
            ->first();
    }
}
