Created
June 18, 2018 15:16
-
-
Save artemrogov/7b8f1a012f15348754e19338098be9e4 to your computer and use it in GitHub Desktop.
ManyToMany RelationShips Products vs CategoryProducts
This file contains hidden or 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
class CreateTbPivotCatProducts extends Migration | |
{ | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create('products_has_categories', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->integer('product_id')->unsigned(); | |
$table->foreign('product_id')->references('id')->on('products'); | |
$table->integer('category_product_id')->unsigned(); | |
$table->foreign('category_product_id')->references('id')->on('category_products'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists('products_has_categories'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment