<?php

namespace app\common\model;

use think\Model;

class ResidentLog extends Model
{

    // 设置字段信息
    protected $schema = [
        'id'         => 'int',
        'userid'     => 'int',
        'residentid' => 'int',
        'workerid'   => 'int',
        'content'    => 'string',
        'createtime' => 'int',
    ];

    // 设置字段自动转换类型
    protected $type = [
        'createtime' => 'timestamp:Y-m-d H:i:s',
    ];

    // 关联User
    public function user()
    {
        return $this->hasOne(User::class, "id", "userid");
    }

    // 关联resident
    public function resident()
    {
        return $this->hasOne(Resident::class, "id", "residentid");
    }

    // 关联worker
    public function worker()
    {
        return $this->hasOne(Worker::class, "id", "workerid");
    }
}