43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
|
|
if (file_exists(__DIR__ . '/.env')) {
|
|
$dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__);
|
|
$dotenv->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";
|
|
} |