<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class CleanupBannerGroups extends Command
{
    protected $signature = 'banners:cleanup-group {group}';
    protected $description = 'Delete all banners from a specific group';

    public function handle()
    {
        $group = $this->argument('group');
        
        $count = DB::table('banners')->where('group', $group)->count();
        
        if ($count === 0) {
            $this->info("No banners found in group '{$group}'");
            return 0;
        }
        
        if ($this->confirm("Delete {$count} banner(s) from group '{$group}'?", true)) {
            DB::table('banners')->where('group', $group)->delete();
            $this->info("Deleted {$count} banner(s) from group '{$group}'");
        } else {
            $this->info('Cancelled');
        }
        
        return 0;
    }
}
