@@ -116,7 +116,7 @@
@@ -166,7 +167,7 @@
-
-
+
@@ -186,6 +188,7 @@
{{ __('admin::app.catalog.attributes.yes') }}
+
diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php
index 5524ebae9..35b3779ac 100644
--- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php
+++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php
@@ -22,20 +22,23 @@ class AttributeFamilyTableSeeder extends Seeder
"position" => 1,
"attributes" => [
[
- 'code' => 'name',
+ 'code' => 'sku',
'position' => 1
], [
- 'code' => 'url_key',
+ 'code' => 'name',
'position' => 2
], [
- 'code' => 'new_from',
+ 'code' => 'url_key',
'position' => 3
], [
- 'code' => 'new_to',
+ 'code' => 'new_from',
'position' => 4
], [
- 'code' => 'status',
+ 'code' => 'new_to',
'position' => 5
+ ], [
+ 'code' => 'status',
+ 'position' => 6
]
]
], [
diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php
index 9937f945a..89ee1e0e5 100644
--- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php
+++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php
@@ -12,13 +12,28 @@ class AttributeTableSeeder extends Seeder
*/
protected $rawData = [
[
+ 'code' => 'sku',
+ 'admin_name' => 'SKU',
+ 'en' => [
+ 'name' => 'SKU'
+ ],
+ 'type' => 'text',
+ 'position' => 1,
+ 'is_unique' => 1,
+ 'is_required' => 1,
+ 'value_per_locale' => 0,
+ 'value_per_channel' => 0,
+ 'is_filterable' => 1,
+ 'is_configurable' => 0,
+ 'is_user_defined' => 0
+ ], [
'code' => 'name',
'admin_name' => 'Name',
'en' => [
'name' => 'Name'
],
'type' => 'text',
- 'position' => 1,
+ 'position' => 2,
'is_required' => 1,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -32,7 +47,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'URL Key'
],
'type' => 'text',
- 'position' => 2,
+ 'position' => 3,
'is_unique' => 1,
'is_required' => 1,
'value_per_locale' => 0,
@@ -47,7 +62,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'New From'
],
'type' => 'datetime',
- 'position' => 3,
+ 'position' => 4,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -61,7 +76,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'New To'
],
'type' => 'datetime',
- 'position' => 4,
+ 'position' => 5,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -75,7 +90,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Status'
],
'type' => 'boolean',
- 'position' => 5,
+ 'position' => 6,
'is_required' => 1,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -89,7 +104,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Short Description'
],
'type' => 'textarea',
- 'position' => 6,
+ 'position' => 7,
'is_required' => 1,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -103,7 +118,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Description'
],
'type' => 'textarea',
- 'position' => 7,
+ 'position' => 8,
'is_required' => 1,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -117,7 +132,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Price'
],
'type' => 'price',
- 'position' => 8,
+ 'position' => 9,
'is_required' => 1,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -131,7 +146,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Cost'
],
'type' => 'price',
- 'position' => 9,
+ 'position' => 10,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -145,7 +160,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Special Price'
],
'type' => 'price',
- 'position' => 10,
+ 'position' => 11,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -159,7 +174,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Special Price From'
],
'type' => 'datetime',
- 'position' => 11,
+ 'position' => 12,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -173,7 +188,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Special Price To'
],
'type' => 'datetime',
- 'position' => 12,
+ 'position' => 13,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -187,7 +202,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Meta Description'
],
'type' => 'textarea',
- 'position' => 13,
+ 'position' => 14,
'is_required' => 0,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -201,7 +216,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Meta Keywords'
],
'type' => 'textarea',
- 'position' => 14,
+ 'position' => 15,
'is_required' => 0,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -215,7 +230,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Meta Description'
],
'type' => 'textarea',
- 'position' => 15,
+ 'position' => 16,
'is_required' => 0,
'value_per_locale' => 1,
'value_per_channel' => 1,
@@ -230,7 +245,7 @@ class AttributeTableSeeder extends Seeder
],
'type' => 'text',
'validation' => 'number',
- 'position' => 16,
+ 'position' => 17,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -245,7 +260,7 @@ class AttributeTableSeeder extends Seeder
],
'type' => 'text',
'validation' => 'number',
- 'position' => 17,
+ 'position' => 18,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -260,7 +275,7 @@ class AttributeTableSeeder extends Seeder
],
'type' => 'text',
'validation' => 'number',
- 'position' => 18,
+ 'position' => 19,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -275,7 +290,7 @@ class AttributeTableSeeder extends Seeder
],
'type' => 'text',
'validation' => 'number',
- 'position' => 19,
+ 'position' => 20,
'is_required' => 1,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -289,7 +304,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Color'
],
'type' => 'select',
- 'position' => 20,
+ 'position' => 21,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
@@ -331,7 +346,7 @@ class AttributeTableSeeder extends Seeder
'name' => 'Size'
],
'type' => 'select',
- 'position' => 21,
+ 'position' => 22,
'is_required' => 0,
'value_per_locale' => 0,
'value_per_channel' => 0,
diff --git a/packages/Webkul/Product/src/Database/Migrations/2018_07_27_065727_create_products_table.php b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_065727_create_products_table.php
new file mode 100644
index 000000000..d11c3312a
--- /dev/null
+++ b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_065727_create_products_table.php
@@ -0,0 +1,68 @@
+increments('id');
+ $table->string('sku')->unique();
+ $table->string('type');
+ $table->integer('parent_id')->unsigned()->nullable();
+ $table->timestamps();
+ });
+
+ Schema::table('products', function (Blueprint $table) {
+ $table->foreign('parent_id')->references('id')->on('products')->onDelete('cascade');
+ });
+
+ Schema::create('product_categories', function (Blueprint $table) {
+ $table->integer('product_id')->unsigned();
+ $table->integer('category_id')->unsigned();
+ $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
+ });
+
+ Schema::create('product_relations', function (Blueprint $table) {
+ $table->integer('parent_id')->unsigned();
+ $table->integer('child_id')->unsigned();
+ $table->foreign('parent_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('child_id')->references('id')->on('products')->onDelete('cascade');
+ });
+
+ Schema::create('product_up_sells', function (Blueprint $table) {
+ $table->integer('parent_id')->unsigned();
+ $table->integer('child_id')->unsigned();
+ $table->foreign('parent_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('child_id')->references('id')->on('products')->onDelete('cascade');
+ });
+
+ Schema::create('product_cross_sells', function (Blueprint $table) {
+ $table->integer('parent_id')->unsigned();
+ $table->integer('child_id')->unsigned();
+ $table->foreign('parent_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('child_id')->references('id')->on('products')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('products');
+
+ Schema::dropIfExists('product_categories');
+ }
+}
diff --git a/packages/Webkul/Product/src/Database/Migrations/2018_07_27_070011_create_product_attribute_value_table.php b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_070011_create_product_attribute_value_table.php
new file mode 100644
index 000000000..376626147
--- /dev/null
+++ b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_070011_create_product_attribute_value_table.php
@@ -0,0 +1,41 @@
+increments('id');
+ $table->text('text_value')->nullable();
+ $table->boolean('boolean_value')->nullable();
+ $table->integer('integer_value')->nullable();
+ $table->double('float_value')->nullable();
+ $table->dateTime('datetime_value')->nullable();
+ $table->date('date_value')->nullable();
+ $table->json('json_value')->nullable();
+ $table->integer('product_id')->unsigned();
+ $table->integer('attribute_id')->unsigned();
+ $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('attribute_id')->references('id')->on('attributes')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('product_attribute_value');
+ }
+}
diff --git a/packages/Webkul/Product/src/Database/Migrations/2018_07_27_092623_create_product_reviews_table.php b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_092623_create_product_reviews_table.php
new file mode 100644
index 000000000..7a244e715
--- /dev/null
+++ b/packages/Webkul/Product/src/Database/Migrations/2018_07_27_092623_create_product_reviews_table.php
@@ -0,0 +1,39 @@
+increments('id');
+ $table->string('title');
+ $table->integer('rating');
+ $table->text('comment')->nullable();
+ $table->string('status');
+ $table->timestamps();
+ $table->integer('product_id')->unsigned();
+ $table->integer('customer_id')->unsigned();
+ $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
+ $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('product_reviews');
+ }
+}
diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php
index 4a0fd94a2..7984de298 100644
--- a/packages/Webkul/Product/src/Models/Product.php
+++ b/packages/Webkul/Product/src/Models/Product.php
@@ -3,8 +3,17 @@
namespace Webkul\Product\Models;
use Illuminate\Database\Eloquent\Model;
+use Webkul\Category\Models\Category;
class Product extends Model
{
protected $guarded = ['_token'];
+
+ /**
+ * The categories that belong to the product.
+ */
+ public function categories()
+ {
+ return $this->belongsToMany(Category::class, 'product_categories');
+ }
}
\ No newline at end of file