<?php

namespace App\Models\Cultura\ArteSacra;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class HistoriaArte extends Model
{
    use HasFactory;

    protected $connection = 'mysql_arte_sacra';
    protected $table = 'historia_arte';
    public $incrementing = false;
    protected $keyType = 'string';

    protected $fillable = [
        'id',
        'acervo_id',
        'historia_obra'
    ];

    protected static function boot()
    {
        parent::boot();
        static::creating(function ($model) {
            if (empty($model->id)) {
                $model->id = (string) Str::uuid();
            }
        });
    }

    public function acervo()
    {
        return $this->belongsTo(Acervo::class, 'acervo_id');
    }
}
