_config = request('_config'); $this->customerRepository = $customerRepository; $this->customerGroupRepository = $customerGroupRepository; } /** * Method to store user's sign up form data to DB. * * @return \Illuminate\Http\Response */ public function create() { request()->validate([ 'first_name' => 'required', 'last_name' => 'required', 'email' => 'email|required|unique:customers,email', 'password' => 'confirmed|min:6|required', ]); $data = request()->input(); $data = array_merge($data, [ 'password' => bcrypt($data['password']), 'channel_id' => core()->getCurrentChannel()->id, 'is_verified' => 1, ]); $data['customer_group_id'] = $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id; Event::dispatch('customer.registration.before'); $customer = $this->customerRepository->create($data); Event::dispatch('customer.registration.after', $customer); return response()->json([ 'message' => 'Your account has been created successfully.', ]); } }