<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class Content extends Model
{
    protected $table = 'content';

    protected $primaryKey = 'content_id';

    protected $dateFormat = 'U';

    const CREATED_AT = 'content_addtimes';

    const UPDATED_AT = 'content_updatetimes';

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

    public function category(){
        return $this->hasOne(SysCategory::class,'category_id','join_content_category_id')
            ->select('category_id','category_name');
    }

    public function user(){
        return $this->hasOne(SysUser::class,'user_id','creator_user_id')
            ->select('user_id','user_name');
    }
}