<?php

namespace App\Console\Commands;

use App\Models\Admin;
use App\Models\User;
use Illuminate\Console\Command;

class AddAdmin extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:add-admin';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create new admin';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $admin = Admin::create();

        $user = User::create([
            'email' => 'admin' . $admin->id . '@mail',
            'password' => 'password',
        ]);

        $admin->user()->save($user);

        $this->info('Admin created successfully!');
        $this->info('email = ' . $user->email);
        $this->info('password = password');
    }
}