Skip to content

Commit

Permalink
Merge pull request #79 from avored/dev
Browse files Browse the repository at this point in the history
merge dev to master
  • Loading branch information
indpurvesh authored Jul 17, 2019
2 parents 2b1ee05 + c4db023 commit a9eda71
Show file tree
Hide file tree
Showing 103 changed files with 2,247 additions and 348 deletions.
53 changes: 51 additions & 2 deletions database/migrations/2017_03_29_000000_avored_framework_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,30 @@ public function up()
$table->foreign('order_status_id')->references('id')->on('order_statuses');
});

Schema::create('order_product', function (Blueprint $table) {
Schema::create('order_products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('product_id');
$table->unsignedBigInteger('order_id');
$table->decimal('qty', 11, 6);
$table->decimal('price', 11, 6);
$table->decimal('tax_amount', 11, 6);
$table->json('product_info')->nullable()->default(null);
$table->timestamps();
$table->foreign('order_id')->references('id')->on('orders');
$table->foreign('product_id')->references('id')->on('products');
});

Schema::create('order_product_attributes', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('order_product_id');
$table->unsignedBigInteger('attribute_id');
$table->unsignedBigInteger('attribute_dropdown_option_id');
$table->timestamps();

$table->foreign('order_product_id')->references('id')->on('order_products');
$table->foreign('attribute_id')->references('id')->on('attributes');
$table->foreign('attribute_dropdown_option_id')->references('id')->on('attribute_dropdown_options');
});

Schema::create('category_filters', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('category_id');
Expand All @@ -428,6 +439,40 @@ public function up()
$table->timestamps();
});

Schema::create('attribute_product', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('attribute_id');
$table->unsignedBigInteger('product_id');

$table->foreign('attribute_id')->references('id')->on('attributes');
$table->foreign('product_id')->references('id')->on('products');
$table->timestamps();
});

Schema::create('attribute_product_values', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('attribute_id');
$table->unsignedBigInteger('product_id');
$table->unsignedBigInteger('variation_id');
$table->unsignedBigInteger('attribute_dropdown_option_id');

$table->foreign('attribute_id')->references('id')->on('attributes');
$table->foreign('product_id')->references('id')->on('products');
$table->foreign('variation_id')->references('id')->on('products');
$table->foreign('attribute_dropdown_option_id')->references('id')->on('attribute_dropdown_options');
$table->timestamps();
});

Schema::create('product_variations', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('variation_id');
$table->unsignedBigInteger('product_id');

$table->foreign('variation_id')->references('id')->on('products')->onDelete('cascade');
$table->foreign('product_id')->references('id')->on('products');
$table->timestamps();
});

$path = __DIR__ . '/../../assets/countries.json';
$json = json_decode(file_get_contents($path), true);
foreach ($json as $country) {
Expand All @@ -451,6 +496,10 @@ public function down()
{
Schema::disableForeignKeyConstraints();


Schema::dropIfExists('attribute_product');
Schema::dropIfExists('attribute_product_values');
Schema::dropIfExists('product_variations');
Schema::dropIfExists('category_filters');
Schema::dropIfExists('addresses');
Schema::dropIfExists('order_product');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import isNil from 'lodash/isNil'
const columns = [
{
Expand All @@ -24,13 +25,35 @@ const columns = [
export default {
props: ['baseUrl'],
props: ['baseUrl', 'attributes'],
data () {
return {
columns
};
},
methods: {
handleTableChange(pagination, filters, sorter) {
this.attributes.sort(function(a, b){
let columnKey = sorter.columnKey
let order = sorter.order
if (isNil(a[columnKey])) {
a[columnKey] = ''
}
if (isNil(b[columnKey])) {
b[columnKey] = ''
}
if (order === 'ascend'){
if(a[columnKey] < b[columnKey]) return -1;
if(a[columnKey] > b[columnKey]) return 1;
}
if (order === 'descend') {
if(a[columnKey] > b[columnKey]) return -1;
if(a[columnKey] < b[columnKey]) return 1;
}
return 0;
});
},
getEditUrl(record) {
return this.baseUrl + '/attribute/' + record.id + '/edit';
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import isNil from 'lodash/isNil';
const columns = [
{
Expand Down Expand Up @@ -30,13 +31,35 @@ const columns = [
export default {
props: ['baseUrl'],
props: ['baseUrl', 'categoryData'],
data () {
return {
columns
columns
};
},
methods: {
handleTableChange(pagination, filters, sorter) {
this.categoryData.sort(function(a, b){
let columnKey = sorter.columnKey
let order = sorter.order
if (isNil(a[columnKey])) {
a[columnKey] = ''
}
if (isNil(b[columnKey])) {
b[columnKey] = ''
}
if (order === 'ascend'){
if(a[columnKey] < b[columnKey]) return -1;
if(a[columnKey] > b[columnKey]) return 1;
}
if (order === 'descend') {
if(a[columnKey] > b[columnKey]) return -1;
if(a[columnKey] < b[columnKey]) return 1;
}
return 0;
});
},
getEditUrl(record) {
return this.baseUrl + '/category/' + record.id + '/edit';
},
Expand Down
104 changes: 103 additions & 1 deletion resources/components/catalog/product/ProductSave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,36 @@ import isObject from 'lodash/isObject';
import { quillEditor } from 'vue-quill-editor';
import axios from 'axios'
const columns = [{
dataIndex: 'name',
key: 'name',
title: 'Name',
scopedSlots: { customRender: 'name' },
}, {
title: 'Price',
dataIndex: 'price',
key: 'price',
scopedSlots: { customRender: 'price' },
}, {
title: 'Qty',
dataIndex: 'qty',
key: 'qty',
scopedSlots: { customRender: 'qty' },
}, {
title: 'Action',
key: 'action',
scopedSlots: { customRender: 'action' },
}];
export default {
props: ['product', 'baseUrl', 'productProperties'],
props: ['product', 'baseUrl', 'productProperties', 'productAttributes', 'productVariations'],
components: {
'quil-editor': quillEditor,
},
data () {
return {
productForm: this.$form.createForm(this),
variationForm: this.$form.createForm(this),
type: null,
description: null,
status: 0,
Expand All @@ -20,16 +42,91 @@ export default {
categories: [],
property: {},
productImages: [],
attributeIds: [],
columns,
variationModelVisible: false,
variationFields: ['id', 'name', 'slug', 'barcode', 'sku', 'qty', 'price', 'weight', 'length', 'width', 'height']
};
},
methods: {
clickVariationSave(e) {
this.variationForm.validateFields((err, data) => {
if (isNil(err)) {
let url = this.baseUrl + '/variation/'+ this.product.id +'/save-variation';
var app = this;
axios.post(url, data)
.then(res => {
if (res.data.success) {
app.$notification.success({
key: 'product.save.variation.success',
message: res.data.message,
});
window.location.reload();
} else {
alert('there is an error')
}
})
}
});
},
deleteVariation(model) {
let url = this.baseUrl + '/variation/' + model.variation_id;
var app = this;
axios.delete(url)
.then(res => {
if (res.data.success) {
app.$notification.success({
key: 'product.delete.variation.success',
message: res.data.message,
});
window.location.reload();
} else {
alert('there is an error')
}
})
},
showVariationModel(model) {
this.variationModelVisible = true;
var variationModel = model.variationModel;
this.variationFields.forEach(field => {
this.variationForm.getFieldDecorator(field, {initialValue: variationModel[field]})
});
},
handleSubmit(e) {
this.productForm.validateFields((err, values) => {
if (err !== null) {
e.preventDefault();
}
});
},
handleVariationBtnClick(e) {
let data = { attributes: this.attributeIds};
let url = this.baseUrl + '/variation/'+ this.product.id +'/create-variation';
var app = this;
axios.post(url, data)
.then(res => {
if (res.data.success) {
app.$notification.success({
key: 'product.create.variation.success',
message: res.data.message,
});
window.location.reload();
} else {
alert('there is an error')
}
})
},
changeVariation(values) {
var app = this;
values.forEach(val => {
app.attributeIds.push(val)
});
},
handlePropertyChange(id, val) {
let propertyValue = ''
propertyValue = val
Expand Down Expand Up @@ -94,6 +191,11 @@ export default {
this.productProperties.forEach(record => {
this.property[record.id] = record.product_value.value
});
this.productAttributes.forEach(record => {
this.attributeIds.push(record.id)
});
this.product.images.forEach(record => {
this.productImages.push(record)
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import isNil from 'lodash/isNil'
const columns = [
{
Expand All @@ -24,13 +25,35 @@ const columns = [
export default {
props: ['baseUrl'],
props: ['baseUrl', 'properties'],
data () {
return {
columns
};
},
methods: {
handleTableChange(pagination, filters, sorter) {
this.properties.sort(function(a, b){
let columnKey = sorter.columnKey
let order = sorter.order
if (isNil(a[columnKey])) {
a[columnKey] = ''
}
if (isNil(b[columnKey])) {
b[columnKey] = ''
}
if (order === 'ascend'){
if(a[columnKey] < b[columnKey]) return -1;
if(a[columnKey] > b[columnKey]) return 1;
}
if (order === 'descend') {
if(a[columnKey] > b[columnKey]) return -1;
if(a[columnKey] < b[columnKey]) return 1;
}
return 0;
});
},
getEditUrl(record) {
return this.baseUrl + '/property/' + record.id + '/edit';
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import isNil from 'lodash/isNil'
const columns = [
{
Expand Down Expand Up @@ -30,13 +31,35 @@ const columns = [
export default {
props: ['baseUrl'],
props: ['baseUrl', 'pages'],
data () {
return {
columns
};
},
methods: {
handleTableChange(pagination, filters, sorter) {
this.pages.sort(function(a, b){
let columnKey = sorter.columnKey
let order = sorter.order
if (isNil(a[columnKey])) {
a[columnKey] = ''
}
if (isNil(b[columnKey])) {
b[columnKey] = ''
}
if (order === 'ascend'){
if(a[columnKey] < b[columnKey]) return -1;
if(a[columnKey] > b[columnKey]) return 1;
}
if (order === 'descend') {
if(a[columnKey] > b[columnKey]) return -1;
if(a[columnKey] < b[columnKey]) return 1;
}
return 0;
});
},
getEditUrl(record) {
return this.baseUrl + '/page/' + record.id + '/edit';
},
Expand Down
Loading

0 comments on commit a9eda71

Please sign in to comment.