attribute creation and deletion now syncing with columns of product_flat, label is now also creating when attribute type is select or multiselect

This commit is contained in:
Prashant Singh 2019-01-18 18:49:51 +05:30
parent 50a0a71196
commit 14dfec8365
2 changed files with 14 additions and 2 deletions

View File

@ -75,7 +75,11 @@ class AttributeController extends Controller
'type' => 'required'
]);
$attribute = $this->attribute->create(request()->all());
$data = request()->all();
$data['is_user_defined'] = 1;
$attribute = $this->attribute->create($data);
Event::fire('after.attribute.created', $attribute);

View File

@ -49,8 +49,12 @@ class ProductsFlat
if (Schema::hasTable('product_flat')) {
if (!Schema::hasColumn('product_flat', strtolower($attribute->code))) {
Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode) {
Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode, $attributeType) {
$table->{$columnType}(strtolower($attributeCode))->nullable();
if($attributeType == 'select' || $attributeType == 'multiselect') {
$table->string(strtolower($attributeCode).'_label')->nullable();
}
});
return true;
@ -76,6 +80,10 @@ class ProductsFlat
if (Schema::hasColumn('product_flat', strtolower($attribute->code))) {
Schema::table('product_flat', function (Blueprint $table) use($attribute){
$table->dropColumn(strtolower($attribute->code));
if ($attribute->type == 'select' || $attribute->type == 'multiselect') {
$table->dropColumn(strtolower($attribute->code).'_label');
}
});
return true;