Skip to content

Instantly share code, notes, and snippets.

@haakym
Created December 19, 2017 21:26
Show Gist options
  • Save haakym/1337af326d555b208afef988737ee1bc to your computer and use it in GitHub Desktop.
Save haakym/1337af326d555b208afef988737ee1bc to your computer and use it in GitHub Desktop.
Hotel Schema
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Bookings extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bookings', function (Blueprint $table) {
$table->increments('id');
// ... other fields
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bookings');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Reservations extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('reservations', function (Blueprint $table) {
$table->increments('id');
$table->string('type'); // (single, double, triple, etc.)
$table->string('room_no');
$table->unsignedInteger('booking_id');
$table->timestamps();
$table->foreign('booking_id')
->references('id')
->on('bookings');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('reservations');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Customers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->string('type'); // guest, company, trader
$table->string('name');
$table->string('email');
$table->string('phone');
$table->text('address');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('customers');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Invoices extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->decimal('price', 5, 2);
$table->unsignedInteger('reservation_id');
$table->unsignedInteger('customer_id');
$table->timestamps();
$table->foreign('reservation_id')
->references('id')
->on('reservations');
$table->foreign('customer_id')
->references('id')
->on('customers');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('invoices');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment