Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Kovah/LinkAce

3159 stars
1 code files
View Kovah/LinkAce on GitHub

app/Console/Commands/CleanupLinkHistoriesCommand.php

Open in GitHub
use App\Models\Link;
use Illuminate\Console\Command;
use Venturecraft\Revisionable\Revision;
 
class CleanupLinkHistoriesCommand extends Command
{
public function handle(): void
{
$baseQuery = Revision::where('revisionable_type', Link::class);
 
if ($this->argument('field')) {
$baseQuery->where('key', $this->argument('field'));
}
 
$count = $baseQuery->count();
 
if ($count === 0) {
$this->warn(sprintf('No history entries%s found!', ($this->argument('field') ? ' for this field ' : '')));
return;
}
 
$linkCount = $baseQuery->groupBy('revisionable_id')->count('revisionable_id');
 
$this->info(" Found $count entries across $linkCount links.");
//
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.