12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- class CouponsUserBag extends Model
- {
- //
- use ModelHelpers;
- protected $table = "coupons_user_bags";
- protected $guarded = [];
- const TYPE_ADMIN_GIVE = 1;
- const TYPE_INVITE_NEW_GIVE = 2;
- public static $typeMaps = [
- self::TYPE_ADMIN_GIVE => '后台管理员赠送',
- self::TYPE_INVITE_NEW_GIVE => '邀请新用户赠送',
- ];
- const STATUS_OK = 1;
- const STATUS_NO = 0;
- const STATUS_USED = 2;
- public static $statusMaps = [
- self::STATUS_OK=>'启用',
- self::STATUS_NO=>'停用',
- self::STATUS_USED=>'已使用',
- ];
- const VALID_TYPE_ABSOLUTELY = 1;
- const VALID_TYPE_RELATIVE = 2;
- public static $validTypeMaps = [
- self::VALID_TYPE_ABSOLUTELY => '绝对时效',
- self::VALID_TYPE_RELATIVE => '相对时效',
- ];
- const ORDER_TYPE_NORMAL = 1;
- const ORDER_TYPE_RENT = 2;
- const ORDER_TYPE_ALL = 3;
- public static $orderTypeMaps = [
- self::ORDER_TYPE_NORMAL => '仅普通订单可用',
- self::ORDER_TYPE_RENT => '仅日租订单可用',
- self::ORDER_TYPE_ALL => '所有订单可用',
- ];
- public function getCouponsDataAttribute($value)
- {
- return json_decode($value,true);
- }
- public function setCouponsDataAttribute($value)
- {
- $this->attributes['coupons_data'] = json_encode($value);
- }
- public function users(){
- return $this->belongsTo(User::class,'user_id','id');
- }
- public function coupons(){
- return $this->belongsTo(Coupon::class,'coupon_id','id');
- }
- }
|