Favourite.php 518 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Model;
  5. class Favourite extends Model
  6. {
  7. protected $type=[
  8. 'tax'=>'json',
  9. ];
  10. protected $autoWriteTimestamp=true;
  11. protected $updateTime=null;
  12. protected $createTime='created_at';
  13. public function goods(){
  14. return $this->belongsTo(Goods::class,'fav_id');
  15. }
  16. public static function delNotExists(){
  17. self::whereNotExists(GoodsSku::where('id',Db::raw('favourite.goods_sku_id'))->buildSql())->delete();
  18. }
  19. }