<?php

namespace App\Console\Commands;

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

class NotifyRemoveChannel extends Command
{
    protected $signature = 'notify:remove-channel {id}';
    protected $description = 'Remove a notification channel.';

    public function handle(): int
    {
        $id = $this->argument('id');
        $row = DB::table('notification_channels')->where('id', $id)->first();
        if (! $row) {
            $this->error("Channel #{$id} not found.");
            return self::FAILURE;
        }
        DB::table('notification_channels')->where('id', $id)->delete();
        $this->info("Removed channel #{$id} ({$row->type} · {$row->label}).");
        return self::SUCCESS;
    }
}
