<?php
declare(strict_types=1);

namespace app\common\model;

use think\Model;

class ImportList Extends Model
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $type = [
        'createtime'     =>  'timestamp:Y-m-d H:i',
        'updatetime'     =>  'timestamp:Y-m-d H:i',
    ];

    public static function onAfterInsert($data)
    {
        $data->weigh=1000-$data->id;
        $data->save();
    }
    //获取最后一条记录
    public static function getLastRecord()
    {
        return self::order('id','desc')->getByName('createtime');
    }
}
