Files
timebank-cc-public/app/Console/Commands/RegisterPostsAsReactants.php
Ronald Huynen 2547717edb Initial commit
2026-03-23 21:37:59 +01:00

51 lines
1.1 KiB
PHP

<?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;
}
}