Ejemplo n.º 1
0
 public function createCompanyJob(CompanyService $company, GoogleApiService $google, $user_id, $company_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->createCompanyJob($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']]);
             }
         } else {
             return $this->json_response->error(['validation_message' => $validation->messages()]);
         }
     } catch (Exception $e) {
         return $this->json_response->error(['error' => $e->getMessage()]);
     }
 }