A lot of things
This commit is contained in:
31
app/Console/Commands/PurgeFeaturedEntries.php
Normal file
31
app/Console/Commands/PurgeFeaturedEntries.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Entry;
|
||||
|
||||
#[Signature('entries:purge-featured {--days=15}')]
|
||||
#[Description('Remove Featured from entries higher than X days')]
|
||||
class PurgeFeaturedEntries extends Command
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$days = $this->option('days');
|
||||
|
||||
$cutoff = now()->subDays($days);
|
||||
|
||||
$count = Entry::query()
|
||||
->where('featured', true)
|
||||
->where('featured_at', '<=', $cutoff)
|
||||
->update([
|
||||
'featured' => false,
|
||||
'featured_at' => null,
|
||||
]);
|
||||
|
||||
$this->info("$count entr" . ($count > 1 ? 'ies' : 'y') . " unfeatured.");
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user