| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | 
							- <?php
 
- namespace app\model;
 
- use DateTimeInterface;
 
- use support\Model;
 
- class Goods extends Model
 
- {
 
-     protected $table = 'goods';
 
-     protected $primaryKey = 'goods_id';
 
-     protected $keyType = 'string';
 
-     public $incrementing = false;
 
-     protected $dateFormat = 'U';
 
-     const CREATED_AT = 'goods_addtimes';
 
-     const UPDATED_AT = null;
 
-     // 自动上架
 
-     const LISTING_KEY_PREFIX = "GOODS:LISTING:ON:";
 
-     // 自动下架
 
-     const LISTING_OFF_KEY_PREFIX = "GOODS:LISTING:OFF:";
 
-     public function serializeDate(DateTimeInterface $date)
 
-     {
 
-         return $date->format('Y-m-d H:i:s');
 
-     }
 
-     /**
 
-      * @Desc 关联分类
 
-      * @Author Gorden
 
-      * @Date 2024/3/28 9:36
 
-      *
 
-      * @return \Illuminate\Database\Eloquent\Relations\HasOne
 
-      */
 
-     public function category()
 
-     {
 
-         return $this->hasOne(SysCategory::class, 'category_id', 'join_goods_category_id');
 
-     }
 
-     /**
 
-      * @Desc 关联GoodsRunning
 
-      * @Author Gorden
 
-      * @Date 2024/3/28 10:04
 
-      *
 
-      * @return \Illuminate\Database\Eloquent\Relations\HasOne
 
-      */
 
-     public function running()
 
-     {
 
-         return $this->hasOne(GoodsRunning::class, 'join_running_goods_id', 'goods_id');
 
-     }
 
-     public function supplier()
 
-     {
 
-         return $this->hasOne(Supplier::class, 'supplier_id', 'join_goods_supplier_id');
 
-     }
 
-     public function component()
 
-     {
 
-         return $this->hasMany(GoodsComponent::class,'join_component_master_goods_id','goods_id');
 
-     }
 
- }
 
 
  |