1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\common\model\store\product;
- use app\common\model\BaseModel;
- use app\common\model\system\merchant\Merchant;
- class ProductGroupBuying extends BaseModel
- {
- /**
- * TODO
- * @return string
- * @author Qinii
- * @day 1/7/21
- */
- public static function tablePk(): string
- {
- return 'group_buying_id';
- }
- /**
- * TODO
- * @return string
- * @author Qinii
- * @day 1/7/21
- */
- public static function tableName(): string
- {
- return 'store_product_group_buying';
- }
- public function getStopTimeAttr()
- {
- return date('Y-m-d H:i:s',$this->end_time);
- }
- public function groupUser()
- {
- return $this->hasMany(ProductGroupUser::class,'group_buying_id','group_buying_id');
- }
- public function initiator()
- {
- return $this->hasOne(ProductGroupUser::class,'group_buying_id','group_buying_id')->where('is_initiator',1);
- }
- public function productGroup()
- {
- return $this->hasOne(ProductGroup::class,'product_group_id','product_group_id');
- }
- public function merchant()
- {
- return $this->hasOne(Merchant::class,'mer_id','mer_id');
- }
- public function searchEndTimeAttr($query,$value)
- {
- $query->where('end_time','<=',$value);
- }
- public function searchStatusAttr($query,$value)
- {
- $query->where('status',$value);
- }
- public function searchIsDelAttr($query,$value)
- {
- $query->where('is_del',$value);
- }
- public function searchProductGroupIdAttr($query,$value)
- {
- $query->where('product_group_id',$value);
- }
- public function searchGroupBuyingIdAttr($query,$value)
- {
- $query->where('group_buying_id',$value);
- }
- }
|