Skip to content

Instantly share code, notes, and snippets.

@cbrhex
Created October 8, 2016 10:03
Show Gist options
  • Save cbrhex/05b66553263b86304395ecbc2aa558ea to your computer and use it in GitHub Desktop.
Save cbrhex/05b66553263b86304395ecbc2aa558ea to your computer and use it in GitHub Desktop.
// 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