Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Schema::create('products', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('slug');
- $table->text('description');
- $table->string('tags');
- $table->string('original_price');
- $table->integer('view_order')->default(0);
- $table->unsignedInteger('admin_id');
- $table->foreign('admin_id')->references('id')->on('admins');
- $table->boolean('status');
- $table->timestamps();
- });
- Schema::create('categories', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->boolean('status');
- $table->timestamps();
- });
- Schema::create('product_categories', function (Blueprint $table) {
- $table->increments('id');
- $table->unsignedInteger('product_id');
- $table->foreign('product_id')->references('id')->on('products');
- $table->unsignedInteger('category_id');
- $table->foreign('category_id')->references('id')->on('categories');
- $table->timestamps();
- });
- /**
- * @return IlluminateDatabaseEloquentRelationsBelongsToMany
- */
- public function products()
- {
- return $this->belongsToMany(Product::class);
- }
- /**
- * @return IlluminateDatabaseEloquentRelationsBelongsToMany
- */
- public function categories()
- {
- return $this->belongsToMany(Category::class);
- }
Add Comment
Please, Sign In to add comment