Project.php 823 字节
<?php

namespace app\admin\model\inspection;

use think\Model;


class Project extends Model
{

    // 表名
    protected $name = 'inspection_project';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    protected static function init()
    {
        self::afterDelete(function ($row) {
            $model = new Projectitem();
            $model->where(['project_id'=>$row['id']])->delete();
        });
    }

    public function staff() {
        return $this->belongsTo('app\admin\model\inspection\Staff', 'staff_id', 'id', [], 'LEFT')->setEagerlyType(0)
            ->bind(['staff_name' => 'staff_name', 'mobile' => 'mobile']);
    }
}