<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class QuotationSetting extends Model
{
    protected $fillable = [
        'prefix',
        'next_number',
        'number_length',
        'format',
        'validity_days',
        'terms',
        'notes',
        'require_salesperson',
        'show_salesperson_on_pdf',
    ];

    protected function casts(): array
    {
        return [
            'validity_days' => 'integer',
            'require_salesperson' => 'boolean',
            'show_salesperson_on_pdf' => 'boolean',
        ];
    }

    public static function getSettings(): self
    {
        return static::firstOrCreate([], [
            'prefix' => 'QUO',
            'next_number' => 1,
            'number_length' => 6,
            'format' => '{prefix}-{number}',
            'validity_days' => 30,
        ]);
    }
}
