<?php

namespace App\Models;

use CodeIgniter\Model;

class DeliveryNotePhotoModel extends Model
{
    protected $table = 'delivery_note_photos';
    protected $primaryKey = 'id';
    protected $returnType = 'array';
    protected $useAutoIncrement = true;
    protected $protectFields = true;
    protected $allowedFields = [
        'delivery_note_id', 'section', 'caption', 'file_path',
        'mime', 'size', 'orden', 'created_at',
    ];
    protected $useTimestamps = false;

    public function forDeliveryNote(int $id): array
    {
        return $this->where('delivery_note_id', $id)
            ->orderBy('section')
            ->orderBy('orden')
            ->orderBy('id')
            ->findAll();
    }
}
