<?php

namespace App\Models;

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

class Suscripciones extends Model
{
    use HasFactory, HasSortsTrait;

    protected $table = 'suscripciones';

    protected $fillable = [
        'email',
        'estado'
    ];

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

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

    public function getUpdatedAtAttribute()
    {
        if ($this->attributes['updated_at']) {
            return Carbon::parse($this->attributes['updated_at'])->format('d/m/Y H:i:s');
        }
    }
}
