コード例 #1
0
ファイル: UserController.php プロジェクト: Worklemon/api
 public function update(GoogleApiService $google, $user_id)
 {
     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));
             unset($input['password_confirmation']);
             unset($input['birth_year']);
             unset($input['birth_month']);
             User::where('id', '=', $user_id)->update($input);
             $response = User::where('id', '=', $user_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()]);
     }
 }
コード例 #2
0
ファイル: JobController.php プロジェクト: Worklemon/api
 public function updateCompanyJob(CompanyService $company, GoogleApiService $google, $user_id, $company_id, $job_id)
 {
     $retrieve = ['title', 'description', 'street_name', 'city_town', 'country', 'zip_code', 'search_radius', 'work_hour_fulltime', 'work_hour_parttime', 'work_hour_student_job', 'work_hour_other', 'working_hours', 'work_day_monday', 'work_day_tuesday', 'work_day_wednesday', 'work_day_thursday', 'work_day_friday', 'work_day_saturday', 'work_day_sunday', 'working_days', 'minimum', 'maximum'];
     try {
         $input = Request::only($retrieve);
         $validation = $company->validateJobInformation($input);
         if (!$validation->fails()) {
             $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->updateCompanyJob($company_id, $job_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']]);
             }
         } else {
             return $this->json_response->error(['validation_message' => $validation->messages()]);
         }
     } catch (Exception $e) {
         return $this->json_response->error(['error' => $e->getMessage()]);
     }
 }
コード例 #3
0
ファイル: CompanyController.php プロジェクト: Worklemon/api
 public function updateCompanyV2(CompanyService $company, GoogleApiService $google, $company_id)
 {
     $retrieve = ['email', 'user_id', '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_id = $input['user_id'];
         $user = ['email' => $input['email']];
         User::whereId($user_id)->update($user);
         unset($input['email']);
         unset($input['user_id']);
         if (!empty($response)) {
             return $this->json_response->success($response);
         }
         $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->updateCompany($user_id, $company_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']]);
         }
         return $this->json_response->error($response);
     } catch (Exception $e) {
         return $this->json_response->error(['error' => $e->getMessage()]);
     }
 }