public function create(GoogleApiService $google, UserService $user) { try { $input = Request::all(); $address = $input['street_name'] . ', ' . $input['city_town'] . ', ' . $input['zip_code'] . ', ' . $input['country']; $input['lat'] = 0; $input['lng'] = 0; $geocode = $google->geoCoding($address); if ($geocode['status'] == 'OK') { $input['lat'] = $geocode['lat']; $input['lng'] = $geocode['lng']; $birthday = $input['birth_year'] . '-' . $input['birth_month'] . '-' . $input['birth_date']; $input['birth_date'] = date('Y-m-d', strtotime($birthday)); $input['username'] = $user->setUsername($input['first_name'] . ' ' . $input['last_name']); unset($input['password_confirmation']); unset($input['birth_year']); unset($input['birth_month']); $id = User::insertGetId($input); $user_step = new UserStep(); $user_step->user_id = $new_user->id; $user_step->step1 = 1; $user_step->step2 = 1; $user_step->step3 = 1; $user_step->step4 = 1; $user_step->step5 = 1; $user_step->step6 = 1; $user_step->step7 = 1; $user_step->save(); $response = User::where('id', '=', $id)->first()->toArray(); if (!empty($response)) { return $this->json_response->success($response); } return $this->json_response->error($response); } else { return $this->json_response->error(['validation_message' => $geocode['status']]); } } catch (Exception $e) { return $this->json_response->error(['error' => $e->getMessage()]); } }
public function createCompanyV2(CompanyService $company, GoogleApiService $google) { $retrieve = ['email', 'password', 'password_confirmation', 'name', 'employee_count', 'tax_vat_number', 'description', 'street_name', 'street_number', 'building_name', 'building_floor', 'building_room', 'city_town', 'province', 'region_state', 'zip_code', 'country', 'founded_date', 'founded_month', 'founded_year', 'contact_first_name', 'contact_last_name', 'contact_title', 'contact_phone', 'contact_email', 'status_message']; try { $input = Request::only($retrieve); $user = ['email' => $input['email'], 'password' => Hash::make($input['password'])]; $user_id = User::insertGetId($user); unset($input['email']); unset($input['password']); unset($input['password_confirmation']); $address = $input['street_name'] . ', ' . $input['city_town'] . ', ' . $input['zip_code'] . ', ' . $input['country']; $input['lat'] = 0; $input['lng'] = 0; $geocode = $google->geoCoding($address); if ($geocode['status'] == 'OK') { $input['lat'] = $geocode['lat']; $input['lng'] = $geocode['lng']; $response = $company->createCompany($user_id, $input); if (!empty($response)) { return $this->json_response->success($response); } return $this->json_response->error($response); } else { return $this->json_response->error(['validation_message' => $geocode['status']]); } } catch (Exception $e) { return $this->json_response->error(['error' => $e->getMessage()]); } }