<?php

namespace App\Master\Models;

use Mtc\Crm\Traits\ModelSortAndFilter;
use Mtc\MercuryDataModels\Factories\BodyStyleTypeFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Mtc\MercuryDataModels\Traits\EnsuresSlug;
use Mtc\MercuryDataModels\Traits\OrderByName;
use Stancl\Tenancy\Database\Concerns\CentralConnection;

class BodyStyleType extends Model
{
    use CentralConnection;
    use HasFactory;
    use OrderByName;
    use ModelSortAndFilter;
    use EnsuresSlug;

    /**
     * Table name
     *
     * @var string
     */
    protected $table = 'body_styles';

    /**
     * Mass assign columns
     *
     * @var string[]
     */
    protected $fillable = [
        'name',
        'slug',
        'autotrader_id',
        'type',
    ];

    /**
     * Columns shown in JSON response by default
     *
     * @var string[]
     */
    protected $visible = [
        'id',
        'slug',
        'name',
    ];

    protected static function boot()
    {
        parent::boot();

        self::saving(function (self $bodyStyleType) {
            $bodyStyleType->ensureSlug();
        });
    }

    /**
     * Model factory
     *
     * @return BodyStyleTypeFactory
     */
    protected static function newFactory()
    {
        return BodyStyleTypeFactory::new();
    }
}
