*/ use HasFactory; /** * Stripe states in which the merchant keeps their plan. * "past_due" is included: a card failed, and Stripe is still retrying it. * * @var list */ public const array ACTIVE_STATUSES = ['active', 'trialing', 'past_due']; /** * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * @return BelongsTo */ public function plan(): BelongsTo { return $this->belongsTo(Plan::class); } public function isActive(): bool { return $this->plan_id !== null && in_array($this->status, self::ACTIVE_STATUSES, true); } /** * @return array */ protected function casts(): array { return [ 'current_period_end' => 'datetime', 'cancel_at_period_end' => 'boolean', ]; } }