| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | <?phpnamespace app\admin\model;use think\Model;class Classes extends Model{            // 表名    protected $table = 'classes';        // 自动写入时间戳字段    protected $autoWriteTimestamp = false;    // 定义时间戳字段名    protected $createTime = false;    protected $updateTime = false;    protected $deleteTime = false;    // 追加属性    protected $append = [    ];        protected static function init()    {        self::afterInsert(function ($row) {            $pk = $row->getPk();            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);        });    }        public function school()    {        return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);    }    public function grade()    {        return $this->belongsTo('Grade', 'grade_id', 'id', [], 'LEFT')->setEagerlyType(0);    }}
 |