<?php

namespace App\Models;

/** See CreateAiCorporateSummariesTable's migration comment. */
class AiCorporateSummaryModel extends TenantModel
{
    protected $table            = 'ai_corporate_summaries';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'object';
    protected $useTimestamps    = true;
    protected $createdField     = 'created_at';
    protected $updatedField     = '';

    protected $allowedFields = [
        'corporate_account_id',
        'month',
        'summary_text',
        'data_snapshot',
    ];

    public function forAccountMonth(int $accountId, string $month): ?object
    {
        return $this->where('corporate_account_id', $accountId)->where('month', $month)->first();
    }
}
