<?php

namespace Database\Seeders;

use App\Domains\Auth\Models\Admin;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class AdminSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $email = env('ADMIN_EMAIL');

        if (!$email) {
            return;
        }

        if (Admin::where('email', $email)->exists()) {
            return;
        }

        Admin::create([
            'name' => env('ADMIN_NAME', 'Administrator'),
            'email' => $email,
            'password' => Hash::make(env('ADMIN_PASSWORD')),
        ]);
    }
}