<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Hash;

class ChangeUserPassword extends Command
{
    // Описание команды и аргументы
    protected $signature = 'user:password {email} {password}';
    protected $description = 'Смена пароля пользователя по email';

    public function handle()
    {
        $email = $this->argument('email');
        $password = $this->argument('password');

        $user = User::where('email', $email)->first();

        if (!$user) {
            $this->error("Пользователь с email {$email} не найден!");
            return;
        }

        $user->update([
            'password' => Hash::make($password)
        ]);

        $this->info("Пароль для {$email} успешно обновлен!");
    }
}
