caipan_shop_admin/app/model/Sku.php

33 lines
597 B
PHP
Raw Permalink Normal View History

2022-05-25 11:35:57 +00:00
<?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');
}
}