<?php

namespace App\Entities\Wiki;

use App\Models\Usuarios\UserModel;
use CodeIgniter\Entity\Entity;

class WikiContentEntity extends Entity
{
    protected $attributes = [
        "locale" => null,
        "page_id" => null,
        "editor_data" => null,
        "published_data" => null,
        "last_edit_by" => null,
        "published_by" => null,
        "published_at" => null,
    ];
    protected $casts = [
        "locale" => "string",
        "page_id" => "int",
        "editor_data" => "string",
        "published_data" => "string",
        "last_edit_by" => "int",
        "published_by" => "int",
        "published_at" => "string",
    ];
    public function publish_by() : string
    {
        $m = model(UserModel::class);
        $user = $m->find($this->attributes['published_by']);
        return $user->first_name." ".$user->last_name;
    }

}
