<?php

declare(strict_types=1);

namespace App\Models;

class Note extends BaseModel
{
    protected string $table = 'notes';
    protected string $primaryKey = 'id';

    public function createNote(array $data): int
    {
        return $this->create($data);
    }

    public function getByLeadId(int $leadId): array
    {
        return $this->query(
            "SELECT n.*, u.name as created_by_name
             FROM {$this->table} n
             LEFT JOIN users u ON n.created_by = u.id
             WHERE n.lead_id = :lead_id
             ORDER BY n.created_at DESC
             LIMIT 100",
            ['lead_id' => $leadId]
        );
    }
}
