<?php

namespace App\Models;

use CodeIgniter\Model;

class ApplicationNoteModel extends Model
{
    protected $table         = 'application_notes';
    protected $useTimestamps = false;
    protected $allowedFields = ['job_application_id', 'author_user_id', 'note', 'created_at'];

    public function forApplication(int $applicationId): array
    {
        return $this->select('application_notes.*, users.name as author_name')
            ->join('users', 'users.id = application_notes.author_user_id')
            ->where('job_application_id', $applicationId)
            ->orderBy('application_notes.created_at', 'DESC')
            ->findAll();
    }
}
