<?php

namespace App\Models\ParqueTecnologico;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class Faq extends Model
{
    protected $table = 'parque_tecnologico_faqs';

    public $incrementing = false;

    protected $keyType = 'string';

    protected $fillable = [
        'pergunta',
        'resposta',
        'ordem',
        'status',
    ];

    protected $casts = [
        'status' => 'boolean',
    ];

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

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

    protected function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function scopeAtivas($query)
    {
        return $query->where('status', true);
    }
}

