'未使用', self::STATUS_USED => '已使用', self::STATUS_CLOSE => '已作废', ]; /** * 默认加载的关联 * @var array */ protected $with = ['activity']; /** * Notes: 关联活动 * @Author: 玄尘 * @Date : 2020/6/30 9:40 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function activity() { return $this->belongsTo(Activity::class); } /** * Notes: 卡券状态 * @Author: 玄尘 * @Date : 2020/6/30 9:40 * @return string */ public function getStatusTextAttribute() { return self::STATUS[$this->status] ?? '未知'; } /** * Notes: 是否可以核销 * @Author: 玄尘 * @Date : 2020/6/30 9:41 * @return bool */ public function canRedemption() { return $this->status == ActivityCoupon::STATUS_INIT; } /** * Notes: 是否可以销毁 * @Author: 玄尘 * @Date : 2020/6/30 9:41 * @return bool */ public function canDestroy() { return $this->canRedemption(); } }