Skip to content

Commit

Permalink
Merge pull request #2 from marious/master
Browse files Browse the repository at this point in the history
fix issue
  • Loading branch information
3x1io authored Feb 2, 2023
2 parents 42f49e6 + 126967e commit 9d31fab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 9 additions & 6 deletions src/Models/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ public function features(): BelongsToMany
->withPivot('value');
}


/**
* @return bool
* @param Builder $query
* @return Builder
*/
public function scopeIsActive(): bool
public function scopeIsActive(): Builder
{
return (bool)$this->where('is_active', true);
return $this->where('is_active', true);
}

/**
Expand All @@ -95,11 +97,12 @@ public function scopeDefaultAndFree(Builder $query): Builder
}

/**
* @return bool
* @param Builder $query
* @return Builder
*/
public function scopeFreePlan(): bool
public function scopeFreePlan(): Builder
{
return (bool)$this->where('is_free', true);
return $this->where('is_free', true);
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/Traits/HasPlanSubscription.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TomatoPHP\TomatoSubscription\Traits;
namespace TomatoSubscription\TomatoSubscription\Traits;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -40,9 +40,6 @@ public function subscribedTo($planId): bool
'is_current' => true,
])->first();

if ($plan->is_free) {
return true;
}

return $subscription && $subscription->active();
}
Expand All @@ -60,7 +57,7 @@ public function newPlanSubscription(Plan $plan, Carbon $startDate = null): PlanS
'plan_id' => $plan->getKey(),
'starts_at' => $period->getStartDate(),
'ends_at' => $period->getEndDate()->subDay()->endOfDay(),
'status' => PlanSubscriptionEnum::PENDING,
'status' => PlanSubscriptionEnum::ACTIVE, //
'is_current' => true,
]);
}
Expand Down

0 comments on commit 9d31fab

Please sign in to comment.