Skip to content

Commit

Permalink
Old campaign boosters are now pruned after 90 days of beign deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Jan 19, 2024
1 parent 74ff1ed commit d6e517a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Models/CampaignBoost.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Prunable;

/**
* Class CampaignBoost
Expand All @@ -22,6 +23,7 @@ class CampaignBoost extends Model
{
use Paginatable;
use SoftDeletes;
use Prunable;

/** @var string[] */
protected $fillable = ['user_id', 'campaign_id'];
Expand All @@ -46,4 +48,13 @@ public function inCooldown(): bool
{
return !$this->created_at->isBefore(Carbon::now()->subDays(7));
}

/**
* Automatically prune old elements from the db
* @return \Illuminate\Database\Eloquent\Builder
*/
public function prunable()
{
return static::where('deleted_at', '<=', now()->subDays(90));
}
}

0 comments on commit d6e517a

Please sign in to comment.