<?php
declare(strict_types=1);

namespace App\Models;

final class JobNote extends BaseModel
{
    protected static string $table = 'job_notes';

    public static function forJob(int $jobId): array
    {
        return static::db()->fetchAll(
            "SELECT n.*, CONCAT(u.first_name,' ',u.last_name) AS author_name
             FROM job_notes n
             LEFT JOIN users u ON u.id = n.user_id
             WHERE n.tenant_id = :tid AND n.job_id = :jid
             ORDER BY n.created_at DESC",
            ['tid' => static::tenantId(), 'jid' => $jobId]
        );
    }
}
