migrations and models
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_admin')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_admin');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -11,12 +11,12 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('table_room_types', function (Blueprint $table) {
|
||||
Schema::create('hotels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('address');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->text('name');
|
||||
$table->text('capacity');
|
||||
$table->text('base_price');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('table_room_types');
|
||||
Schema::dropIfExists('hotels');
|
||||
}
|
||||
};
|
||||
31
database/migrations/2025_12_30_222106_create_room_types.php
Normal file
31
database/migrations/2025_12_30_222106_create_room_types.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('room_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('hotel_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->integer('capacity');
|
||||
$table->decimal('base_price', 10, 2);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('room_types');
|
||||
}
|
||||
};
|
||||
@@ -11,9 +11,15 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('table_room_availability', function (Blueprint $table) {
|
||||
Schema::create('room_availability', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('date');
|
||||
$table->boolean('is_available')->default(true);
|
||||
$table->decimal('price_override', 10, 2)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['room_type_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +28,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('table_room_availability');
|
||||
Schema::dropIfExists('room_availability');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('booking_number')->nullable();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('check_in');
|
||||
$table->date('check_out');
|
||||
$table->string('guest_name');
|
||||
$table->string('guest_email')->nullable();
|
||||
$table->string('guest_phone')->nullable();
|
||||
$table->enum('status', ['pending', 'confirmed', 'cancelled', 'completed'])->default('pending');
|
||||
$table->enum('confirmation_type', ['auto', 'manual'])->default('auto');
|
||||
$table->unsignedBigInteger('created_by_user_id')->nullable();
|
||||
$table->timestamp('confirmed_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
}
|
||||
};
|
||||
@@ -11,12 +11,14 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('table_hotels', function (Blueprint $table) {
|
||||
Schema::create('invoices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('booking_id')->constrained()->onDelete('cascade');
|
||||
$table->decimal('amount', 10, 2);
|
||||
$table->string('currency')->default('RUB');
|
||||
$table->string('pdf_path')->nullable();
|
||||
$table->timestamp('issued_at')->useCurrent();
|
||||
$table->timestamps();
|
||||
$table->text('name');
|
||||
$table->text('description');
|
||||
$table->text('address');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +27,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('table_hotels');
|
||||
Schema::dropIfExists('invoices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAdminsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('booking_id')->constrained()->onDelete('cascade');
|
||||
$table->decimal('total_amount', 10, 2);
|
||||
$table->string('status')->default('pending');
|
||||
$table->timestamp('issued_at')->useCurrent();
|
||||
$table->timestamp('due_date')->nullable();
|
||||
$table->string('pdf_path')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoices');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user