<?php
// Add these constants FIRST before anything else
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

$config = require __DIR__ . '/../config/web.php';
(new yii\web\Application($config));

$user = new \app\models\User();
$user->name       = 'Administrator';
$user->username   = 'daraly';
$user->email      = 'admin@moesride.com';
$user->password   = \Yii::$app->security->generatePasswordHash('88889999');
$user->auth_key   = \Yii::$app->security->generateRandomString();
$user->position   = 'admin';
$user->client_id  = 0;
$user->auction_id = 0;

if ($user->save()) {
    echo '<h2 style="color:green">✅ Admin created successfully!</h2>';
    echo '<p>Username: <strong>admin</strong></p>';
    echo '<p>Password: <strong>Admin@123</strong></p>';
    echo '<p style="color:red"><strong>⚠️ DELETE this file immediately after logging in!</strong></p>';
} else {
    echo '<h2 style="color:red">❌ Error:</h2><pre>';
    print_r($user->errors);
    echo '</pre>';
}