<?php namespace App\Models;

use App\Entities\ConfirmacaoEmail\ConfirmacaoEmail;
use App\Entities\Pessoa\Pessoa;
use App\Entities\PessoaFisica\PessoaFisica;
use CodeIgniter\Model;

class ConfirmacaoEmailModel extends ModelEntity
{
    protected $table = 'confirmacao_email';
    protected $primaryKey = 'id';
    protected $returnType = 'array';
    protected $allowedFields = [
        'id_usuario',
        'token',
        'tempo_expiracao',
    ];
    protected $useSoftDeletes = false;
    protected $useTimestamps = true;
    protected $skipValidation = true;
    protected $createdField  = 'criado_em';
    protected $updatedField  = 'alterado_em';

    public function registerConfirmacaoEmail (ConfirmacaoEmail &$confirmacao_email) : void {
        $confirmacao_email_data = $confirmacao_email->toArray();
        unset($confirmacao_email_data['id']);
        unset($confirmacao_email_data['criado_em']);
        unset($confirmacao_email_data['alterado_em']);
        $id_new_confirmacao_email = $this->insert($confirmacao_email_data);
        $confirmacao_email->setId($id_new_confirmacao_email);
    }

}
