1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\model;
- use DateTimeInterface;
- use support\Model;
- class CouponPacket extends Model
- {
- protected $table = 'coupon_packet';
- protected $primaryKey = 'coupon_packet_id';
- protected $keyType = 'string';
- protected $dateFormat = 'U';
- const CREATED_AT = 'coupon_packet_addtimes';
- const UPDATED_AT = null;
- public function serializeDate(DateTimeInterface $date)
- {
- return $date->format('Y-m-d H:i:s');
- }
- public function detail()
- {
- return $this->hasMany(CouponDetail::class,'join_detail_coupon_id','coupon_id');
- }
- public function dept()
- {
- return $this->hasOne(SysDept::class,'dept_id','join_coupon_packet_dept_id')->select('dept_id','dept_name');
- }
- public function category(){
- return $this->hasOne(SysCategory::class,'category_id','join_coupon_packet_category_id')->select('category_id','category_name');
- }
- public function user(){
- return $this->hasOne(SysUser::class,'user_id','join_coupon_packet_user_id')->select('user_id','user_name');
- }
- }
|