<?php

namespace App\Models;

use App\Traits\HasSortsTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TiposSecciones extends Model
{
    use HasFactory, HasSortsTrait;

    protected $table = 'tipos_secciones';

    protected $fillable = [
        'titulo',
        'slug',
        'imagen',
        'orden',
        'opciones',
        'limite_opciones',
        'texto_enriquecido',
        'imagen_upload',
        'multiple_imagen'
    ];

    protected $date = ['created_at', 'updated_at'];

    protected $cast = [
        'created_at' => 'datetime:d-m-Y H:m',
        'updated_at' => 'datetime:d-m-Y H:m',
    ];

    public function setTituloAttribute($value)
    {
        $this->attributes['titulo'] = ucfirst(trim($value));
        $this->attributes['slug'] =  str_slug(trim($value));
    }
}
