<?php
namespace app\model;

use app\model\mall\SpuLimitTime;
use think\Model;
use think\model\relation\HasOne;

class Sku extends Base
{
    public static function onAfterInsert(Model $item)
    {
        $item->sort = $item->id;
        $item->save();
    }

    /**
     * @return HasOne
     */
    public function spu(): HasOne
    {
        return $this->hasOne(Spu::class, 'id', 'spu_id');
    }

    /**
     * 限时折扣
     *
     * @return HasOne
     */
    public function limitTime(): HasOne
    {
        return $this->hasOne(SpuLimitTime::class, 'id', 'spu_activity_id');
    }
}