ShopDelivery.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\common\model;
  4. use think\Model;
  5. class ShopDelivery Extends Model
  6. {
  7. // 自动写入时间戳字段
  8. protected $autoWriteTimestamp = true;
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. protected $type = [
  12. 'createtime' => 'timestamp:Y-m-d H:i',
  13. 'updatetime' => 'timestamp:Y-m-d H:i',
  14. ];
  15. public static function onAfterInsert($data)
  16. {
  17. $data->weigh=1000-$data->id;
  18. $data->save();
  19. }
  20. //id,name
  21. public function user()
  22. {
  23. return $this->hasOne(User::class,'id','user_id')->field('id,nickname');
  24. }
  25. public function customer()
  26. {
  27. return $this->hasOne(Customer::class,'id','customer_id')->field('id,name');
  28. }
  29. public function shops()
  30. {
  31. return $this->hasOne(ShopList::class,'id','shop_id')->field('id,name');
  32. }
  33. public function variety()
  34. {
  35. return $this->hasOne(StockConfig::class,'id','variety_id')->field('id,name');
  36. }
  37. public function specs()
  38. {
  39. return $this->hasOne(ProductConfig::class,'id','spec_id')->field('id,name');
  40. }
  41. }