Created
October 8, 2016 10:03
-
-
Save cbrhex/05b66553263b86304395ecbc2aa558ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// REGIONS | |
Schema::create('regions', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->tinyInteger('code')->unique(); | |
$table->string('title', 25)->unique(); | |
$table->string('image'); | |
$table->string('description', 100); | |
$table->timestamps(); | |
}); | |
// NEWS | |
Schema::create('news', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->string('slug')->unique(); | |
$table->string('title'); | |
$table->text('description'); | |
$table->string('small_description'); | |
$table->string('image'); | |
$table->timestamps(); | |
}); | |
// NEWS REGIONS | |
Schema::create('news_regions', function (Blueprint $table) { | |
$table->integer('news_id')->unsigned(); | |
$table->integer('regions_id')->unsigned(); | |
$table->foreign('news_id')->references('id')->on('news') | |
->onUpdate('cascade')->onDelete('cascade'); | |
$table->foreign('regions_id')->references('id')->on('regions') | |
->onUpdate('cascade')->onDelete('cascade'); | |
$table->primary(['news_id', 'regions_id']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment