Guest User

Untitled

a guest
Mar 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. Schema::create('products', function (Blueprint $table) {
  2. $table->increments('id');
  3. $table->string('name');
  4. $table->string('slug');
  5. $table->text('description');
  6. $table->string('tags');
  7. $table->string('original_price');
  8. $table->integer('view_order')->default(0);
  9. $table->unsignedInteger('admin_id');
  10. $table->foreign('admin_id')->references('id')->on('admins');
  11. $table->boolean('status');
  12. $table->timestamps();
  13. });
  14.  
  15. Schema::create('categories', function (Blueprint $table) {
  16. $table->increments('id');
  17. $table->string('name');
  18. $table->boolean('status');
  19. $table->timestamps();
  20. });
  21.  
  22. Schema::create('product_categories', function (Blueprint $table) {
  23. $table->increments('id');
  24. $table->unsignedInteger('product_id');
  25. $table->foreign('product_id')->references('id')->on('products');
  26. $table->unsignedInteger('category_id');
  27. $table->foreign('category_id')->references('id')->on('categories');
  28. $table->timestamps();
  29. });
  30.  
  31. /**
  32. * @return IlluminateDatabaseEloquentRelationsBelongsToMany
  33. */
  34. public function products()
  35. {
  36. return $this->belongsToMany(Product::class);
  37. }
  38.  
  39. /**
  40. * @return IlluminateDatabaseEloquentRelationsBelongsToMany
  41. */
  42. public function categories()
  43. {
  44. return $this->belongsToMany(Category::class);
  45. }
Add Comment
Please, Sign In to add comment