Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Console\Commands;
use App\Models\Post;
use Illuminate\Console\Command;
class RegisterPostsAsReactants extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'posts:register-reactants';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Register all existing posts as Love reactants';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Registering posts as Love reactants...');
$posts = Post::all();
$registered = 0;
$skipped = 0;
foreach ($posts as $post) {
if (!$post->isRegisteredAsLoveReactant()) {
$post->registerAsLoveReactant();
$registered++;
} else {
$skipped++;
}
}
$this->info("Registered {$registered} posts as reactants.");
$this->info("Skipped {$skipped} posts (already registered).");
$this->info('Done!');
return Command::SUCCESS;
}
}