app/Console/Commands/CleanupLinkHistoriesCommand.php
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."); // }}