for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\DbSnapshots\Commands;
use Illuminate\Console\Command;
use Spatie\DbSnapshots\SnapshotRepository;
class Cleanup extends Command
{
protected $signature = 'snapshot:cleanup {--keep=}';
protected $description = 'Specify how many snapshots to keep and delete the rest';
public function handle()
$snapshots = app(SnapshotRepository::class)->getAll();
$keep = $this->option('keep');
if (! $this->option('keep')) {
$this->warn('No value for option --keep.');
return;
}
$snapshots->splice($keep)->each(function ($snapshot) {
$snapshot->delete();
});