load(); } $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'mysql', 'host' => $_ENV['DB_HOST'] ?? '127.0.0.1', 'port' => $_ENV['DB_PORT'] ?? '3306', 'database' => $_ENV['DB_DATABASE'] ?? '', 'username' => $_ENV['DB_USERNAME'] ?? '', 'password' => $_ENV['DB_PASSWORD'] ?? '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', ]); $capsule->setAsGlobal(); $capsule->bootEloquent(); if (!Capsule::schema()->hasTable('invoices')) { Capsule::schema()->create('invoices', function ($table) { $table->id(); $table->unsignedBigInteger('order_id')->unique(); $table->unsignedBigInteger('user_id')->index(); $table->string('type', 20)->default('company')->comment('company, personal'); $table->string('title', 100); $table->string('tax_no', 50)->nullable(); $table->string('email', 100); $table->decimal('amount', 10, 2)->default(0.00); $table->string('status', 20)->default('pending')->comment('pending, issued, rejected'); $table->string('file_url', 255)->nullable(); $table->timestamps(); }); echo "Table 'invoices' created successfully.\n"; } else { echo "Table 'invoices' already exists.\n"; }