migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('hotels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// If a hotel belongs to a restaurant/business group
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->string('name');
|
||||
$table->string('location')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->decimal('latitude', 10, 7)->nullable();
|
||||
$table->decimal('longitude', 10, 7)->nullable();
|
||||
|
||||
$table->time('check_in_time')->default('14:00')->comment('Standard hotel check-in time');
|
||||
$table->time('check_out_time')->default('12:00')->comment('Standard hotel check-out time');
|
||||
|
||||
// Status: 1 = Active, 0 = Inactive (more standard)
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('hotels');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('floors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('restaurant_id')->nullable();
|
||||
$table->unsignedBigInteger('hotel_id');
|
||||
$table->string('name'); // e.g., Lobby, 1st Floor
|
||||
$table->integer('level')->nullable(); // optional floor number
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('floors');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('room_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Optional link if restaurants own hotels
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
// Each room type belongs to a hotel
|
||||
$table->foreignId('hotel_id')
|
||||
->constrained('hotels')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Basic Info
|
||||
$table->string('name'); // e.g., Deluxe, Suite, Standard
|
||||
$table->integer('capacity')->default(1); // number of guests
|
||||
|
||||
// Room Features (real-world usage)
|
||||
$table->integer('beds')->default(1); // number of beds
|
||||
$table->string('bed_type')->nullable(); // Queen, King, Twin, etc.
|
||||
$table->boolean('has_ac')->default(true);
|
||||
$table->boolean('has_wifi')->default(true);
|
||||
$table->boolean('has_breakfast')->default(false);
|
||||
$table->boolean('is_refundable')->default(true);
|
||||
|
||||
// Pricing (standard hotel structure)
|
||||
$table->decimal('base_price', 10, 2); // base per-night price
|
||||
$table->decimal('weekend_price', 10, 2)->nullable(); // optional weekend price
|
||||
$table->decimal('extra_guest_price', 10, 2)->nullable();
|
||||
|
||||
// Optional description for UI
|
||||
$table->text('description')->nullable();
|
||||
|
||||
// Availability
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('room_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rooms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// If the system belongs to a restaurant group
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
// Main hotel reference
|
||||
$table->foreignId('hotel_id')
|
||||
->constrained('hotels')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Floor reference
|
||||
$table->foreignId('floor_id')
|
||||
->constrained('floors')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Room type reference
|
||||
$table->foreignId('room_type_id')
|
||||
->constrained('room_types')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Room Info
|
||||
$table->string('room_number'); // e.g. 101, 502A
|
||||
$table->string('room_code')->nullable(); // unique internal tracking code (optional)
|
||||
$table->integer('max_adults')->default(2);
|
||||
$table->integer('max_children')->default(0);
|
||||
|
||||
// Features
|
||||
$table->boolean('has_balcony')->default(false);
|
||||
$table->boolean('has_bathtub')->default(false);
|
||||
|
||||
// View type: sea, city, garden, mountain, pool, etc.
|
||||
$table->string('view_type')->nullable();
|
||||
$table->string('slug')->nullable();
|
||||
|
||||
// Media / Images
|
||||
$table->string('image')->nullable(); // main display image
|
||||
$table->string('banner_image')->nullable(); // top banner image
|
||||
$table->json('gallery_images')->nullable(); // multiple images stored as JSON
|
||||
|
||||
// Extra description
|
||||
$table->text('description')->nullable();
|
||||
|
||||
// Pricing
|
||||
$table->decimal('regular_price', 10, 2)->nullable()->comment('Base room price');
|
||||
$table->decimal('offer_price', 10, 2)->nullable()->comment('Discounted price if any');
|
||||
|
||||
// Room Availability
|
||||
$table->boolean('is_clean')->default(true); // housekeeping status
|
||||
$table->boolean('is_available')->default(true); // available or blocked
|
||||
|
||||
// Active/Inactive
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['hotel_id', 'room_number'], 'hotel_room_number_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rooms');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('room_prices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Optional if restaurants own hotels
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->foreignId('room_id')->constrained('rooms')->cascadeOnDelete();
|
||||
|
||||
// Pricing period
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
|
||||
// Day category: normal, weekend, holiday, peak, event
|
||||
$table->enum('day_type', ['normal', 'weekend', 'holiday', 'event', 'peak'])
|
||||
->default('normal');
|
||||
|
||||
// Price for that day/date range
|
||||
$table->decimal('price', 10, 2);
|
||||
|
||||
// For overlapping pricing rules → higher priority wins
|
||||
$table->integer('priority')->default(1);
|
||||
|
||||
// Status
|
||||
$table->boolean('is_active')
|
||||
->default(true)
|
||||
->comment('true = Active, false = Inactive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('room_prices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Optional restaurant group owner
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->foreignId('hotel_id')
|
||||
->constrained('hotels')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Customer (guest)
|
||||
$table->foreignId('customer_id')
|
||||
->constrained('customers')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Stay period
|
||||
$table->date('check_in');
|
||||
$table->date('check_out');
|
||||
|
||||
// optionally store times (if check_in/out only date previously)
|
||||
$table->time('check_in_time')->nullable();
|
||||
$table->time('check_out_time')->nullable();
|
||||
|
||||
// Guest breakdown
|
||||
$table->integer('total_adults')->default(1);
|
||||
$table->integer('total_children')->default(0);
|
||||
|
||||
// Pricing
|
||||
$table->decimal('subtotal_amount', 10, 2)->default(0); // rooms only
|
||||
$table->decimal('tax_amount', 10, 2)->default(0);
|
||||
$table->decimal('discount_amount', 10, 2)->default(0);
|
||||
$table->decimal('total_amount', 10, 2)->default(0);
|
||||
|
||||
// Payment information
|
||||
$table->enum('payment_status', ['pending', 'paid', 'refunded'])->default('pending');
|
||||
$table->enum('payment_method', ['cash', 'card', 'online', 'bank'])->nullable();
|
||||
|
||||
// source/channel (website, ota, walkin)
|
||||
$table->string('channel')->nullable();
|
||||
|
||||
// Booking status
|
||||
$table->enum('status', ['pending', 'confirmed', 'checked_in', 'checked_out', 'canceled'])
|
||||
->default('pending');
|
||||
|
||||
// Cancellation tracking
|
||||
$table->timestamp('canceled_at')->nullable();
|
||||
$table->foreignId('canceled_by')->nullable()->constrained('users');
|
||||
|
||||
// Notes
|
||||
$table->text('remarks')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// small optimization index
|
||||
$table->index(['hotel_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('booking_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('restaurant_id')
|
||||
->nullable()
|
||||
->constrained('restaurants')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->foreignId('booking_id')
|
||||
->constrained('bookings')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreignId('room_id')
|
||||
->constrained('rooms')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Guest count for this room
|
||||
$table->integer('adults')->default(1);
|
||||
$table->integer('children')->default(0);
|
||||
|
||||
// Price assigned to this room (per night * nights)
|
||||
$table->decimal('room_price', 10, 2); // final price for stay (no tax)
|
||||
|
||||
// Calculated nights
|
||||
$table->integer('nights')->default(1);
|
||||
|
||||
$table->decimal('tax_amount', 10, 2)->default(0);
|
||||
$table->decimal('total_amount', 10, 2)->default(0);
|
||||
|
||||
// Housekeeping status (optional)
|
||||
$table->enum('status', ['reserved', 'occupied', 'cleaning', 'completed', 'canceled'])
|
||||
->default('reserved');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('booking_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('room_availabilities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('restaurant_id')->nullable();
|
||||
|
||||
$table->foreignId('hotel_id')
|
||||
->constrained('hotels')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreignId('room_id')
|
||||
->constrained('rooms')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Support multiple room inventory (e.g., 10 deluxe rooms)
|
||||
$table->integer('total_inventory')->default(1);
|
||||
$table->integer('available_inventory')->default(1);
|
||||
|
||||
// Date (1 row per room per date)
|
||||
$table->date('date');
|
||||
|
||||
// Availability flags
|
||||
$table->boolean('is_available')->default(true);
|
||||
$table->boolean('is_closed_to_arrival')->default(false);
|
||||
$table->boolean('is_closed_to_departure')->default(false);
|
||||
|
||||
// Pricing for that day (smart dynamic rate support)
|
||||
$table->decimal('base_price', 10, 2)->nullable();
|
||||
$table->decimal('extra_adult_price', 10, 2)->nullable();
|
||||
$table->decimal('extra_child_price', 10, 2)->nullable();
|
||||
|
||||
// Minimum stay rules
|
||||
$table->integer('min_stay')->default(1);
|
||||
$table->integer('max_stay')->nullable(); // optional
|
||||
|
||||
// Reference to what blocked the inventory
|
||||
$table->foreignId('blocked_by_booking_id')
|
||||
->nullable()
|
||||
->constrained('bookings')
|
||||
->nullOnDelete();
|
||||
|
||||
// Maintenance / admin block info
|
||||
$table->enum('block_type', ['none', 'booking', 'maintenance', 'manual'])->default('none');
|
||||
$table->text('note')->nullable();
|
||||
|
||||
// Status
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Ensures 1 row per room per date
|
||||
$table->unique(['room_id', 'date'], 'room_date_unique');
|
||||
|
||||
$table->index(['hotel_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('room_availabilities');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('room_blocks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('restaurant_id')->nullable();
|
||||
|
||||
$table->foreignId('hotel_id')
|
||||
->nullable()
|
||||
->constrained('hotels')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreignId('room_id')
|
||||
->constrained('rooms')
|
||||
->cascadeOnDelete();
|
||||
|
||||
// Flexible blocking
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
|
||||
// Partial day support
|
||||
$table->time('start_time')->nullable(); // null = full day block
|
||||
$table->time('end_time')->nullable();
|
||||
|
||||
// New: Block type
|
||||
$table->enum('block_type', ['maintenance', 'deep_clean', 'renovation', 'owner_stay', 'event', 'other'])
|
||||
->default('maintenance');
|
||||
|
||||
// Multi-inventory rooms
|
||||
$table->integer('blocked_inventory')->default(1); // e.g., block 1 of 5 room-inventory
|
||||
|
||||
// Priority: higher wins (OTA, admin, system blocks)
|
||||
$table->integer('priority')->default(1);
|
||||
|
||||
// Reason for staff logs
|
||||
$table->string('reason')->nullable();
|
||||
|
||||
// Auto-expire block (optional)
|
||||
$table->boolean('auto_release')->default(true);
|
||||
|
||||
// Who created
|
||||
$table->foreignId('created_by')
|
||||
->nullable()
|
||||
->constrained('users')
|
||||
->nullOnDelete();
|
||||
|
||||
// Active/Inactive
|
||||
$table->smallInteger('status')->default(1)->comment('1=Active, 2=Inactive');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Useful for availability engine
|
||||
$table->index(['room_id', 'start_date', 'end_date']);
|
||||
$table->index(['hotel_id', 'block_type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('room_blocks');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user