<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Каталог поставщиков данных (B1/B2/B3 — суб-поставщики crm.bp-gr.ru).
 *
 * SaaS-уровневая (НЕ tenant-aware): один глобальный каталог на всю систему.
 * Видна всем тенантам через project_suppliers (m2m с проектом).
 *
 * Источник: db/schema.sql v8.7 §2.3, table `suppliers`.
 *
 * @mixin IdeHelperSupplier
 */
class Supplier extends Model
{
    protected $fillable = [
        'code',
        'name',
        'description',
        'accepts_types',
        'cost_rub',
        'settings_schema',
        'channel',
        'supports_sender_name',
        'supports_keyword',
        'supports_csv_upload',
        'supports_domains_list',
        'quality_score',
        'is_active',
        'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'cost_rub' => 'decimal:2',
            'quality_score' => 'decimal:2',
            'supports_sender_name' => 'boolean',
            'supports_keyword' => 'boolean',
            'supports_csv_upload' => 'boolean',
            'supports_domains_list' => 'boolean',
            'is_active' => 'boolean',
            'sort_order' => 'integer',
            'settings_schema' => 'array',
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }
}
