<?php

namespace App\Models;

use CodeIgniter\Model;

class LearningDevicePromesModel extends Model
{
    protected $table            = 'learning_device_promes';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = ['learning_device_id', 'tp_id', 'month', 'week_number', 'allocated_hours'];

    protected $useTimestamps = true;
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';

    // Ambil data Promes per TP
    public function getPromesData(int $deviceId)
    {
        return $this->where('learning_device_id', $deviceId)->findAll() ?? [];
    }
}
