<?php

namespace App\Models;

use CodeIgniter\Model;

class MaintenanceTaskModel extends Model
{
    protected $table         = 'maintenance_tasks';
    protected $primaryKey    = 'id';
    protected $returnType    = 'array';
    protected $useTimestamps = true;
    protected $allowedFields = [
        'organization_id',
        'task_code',
        'name',
        'description',
        'category',
        'estimated_duration_minutes',
        'requires_evidence',
        'status',
    ];

    public function forOrganization(int $organizationId): array
    {
        return $this->where('organization_id', $organizationId)
            ->orderBy('name', 'ASC')
            ->findAll();
    }
}
