diff --git a/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php index 74cd3a83b..c32816dbb 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php @@ -4,11 +4,13 @@ namespace Webkul\API\Http\Controllers\Shop; use Illuminate\Support\Facades\Event; use Webkul\Customer\Repositories\CustomerRepository; +use Webkul\Customer\Repositories\CustomerGroupRepository; /** * Customer controller * * @author Jitendra Singh + * @author Vivek Sharma @vivek-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CustomerController extends Controller @@ -28,13 +30,28 @@ class CustomerController extends Controller protected $customerRepository; /** - * @param CustomerRepository object $customer + * Repository object + * + * @var array */ - public function __construct(CustomerRepository $customerRepository) - { + protected $customerGroupRepository; + + /** + * Create a new controller instance. + * + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository + * @return void + */ + public function __construct( + CustomerRepository $customerRepository, + CustomerGroupRepository $customerGroupRepository + ) { $this->_config = request('_config'); $this->customerRepository = $customerRepository; + + $this->customerGroupRepository = $customerGroupRepository; } /** @@ -56,10 +73,11 @@ class CustomerController extends Controller $data = array_merge($data, [ 'password' => bcrypt($data['password']), 'channel_id' => core()->getCurrentChannel()->id, - 'is_verified' => 1, - 'customer_group_id' => 1 + 'is_verified' => 1 ]); + $data['customer_group_id'] = $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id; + Event::dispatch('customer.registration.before'); $customer = $this->customerRepository->create($data);