diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php index f44575588..f6b4a6dcf 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php @@ -75,7 +75,11 @@ class CustomerGroupController extends Controller 'name' => 'string|required', ]); - $this->customerGroup->create(request()->all()); + $data = request()->all(); + + $data['is_user_defined'] = 1; + + $this->customerGroup->create($data); session()->flash('success', 'Customer Group created successfully.'); @@ -125,22 +129,12 @@ class CustomerGroupController extends Controller { $group = $this->customerGroup->findOneByField('id', $id); - $checked = false; + if($group->is_user_defined == 0) { + session()->flash('warning', 'Cannot delete the default group'); + } else { + session()->flash('success', 'Customer Group deleted successfully'); - if($group->is_user_defined == 1) { - $checked = true; - - session()->flash('warning', 'Cannot delete the last customer group'); - } - - if(!$check) { - if(count($this->customerGroup->all()) == 1) { - session()->flash('warning', 'Cannot delete the last customer group'); - } else { - session()->flash('success', 'Customer Group deleted successfully'); - - $this->customerGroup->delete($id); - } + $this->customerGroup->delete($id); } return redirect()->back(); diff --git a/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php b/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php index 53198bfec..b4457f230 100644 --- a/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php +++ b/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php @@ -14,7 +14,7 @@ class CustomerGroupTableSeeder extends Seeder DB::table('customer_groups')->insert([ 'id' => 1, 'name' => 'General', - 'is_user_defined' => 1, + 'is_user_defined' => 0, ], [ 'id' => 2, 'name' => 'Wholesale',