| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Module\Promotion\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 邀请码使用记录
- *
- * field start
- * field end
- */
- class PromotionReferralCodeUsage extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'promotion_referral_code_usages';
- /**
- * 状态常量
- */
- const STATUS_FAILED = 0;
- const STATUS_SUCCESS = 1;
- const STATUS_REVOKED = 2;
- // attrlist start
- protected $fillable = [
- ];
- // attrlist end
- /**
- * 获取邀请码信息
- *
- * @return BelongsTo
- */
- public function referralCode()
- {
- return $this->belongsTo(PromotionReferralCode::class, 'code', 'code');
- }
- /**
- * 获取邀请码所有者信息
- *
- * @return BelongsTo
- */
- public function codeOwner()
- {
- return $this->belongsTo('App\Models\User', 'code_owner_id');
- }
- /**
- * 获取使用者信息
- *
- * @return BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('App\Models\User', 'user_id');
- }
- /**
- * 判断使用是否成功
- *
- * @return bool
- */
- public function isSuccess(): bool
- {
- return $this->status == self::STATUS_SUCCESS;
- }
- /**
- * 判断使用是否已撤销
- *
- * @return bool
- */
- public function isRevoked(): bool
- {
- return $this->status == self::STATUS_REVOKED;
- }
- }
|