protected function saveExtraDegrees($input, $registration_id)
 {
     $extra_degrees_keys = [];
     $ids = [];
     foreach ($input as $key => $value) {
         if (count($parts = explode('degree_name', $key)) > 1) {
             $extra_degrees_keys[] = $parts[1];
         }
     }
     $extra_degrees = [];
     foreach ($extra_degrees_keys as $key) {
         $data = ['registration_id' => $registration_id, 'degree_name' => $input['degree_name' . $key], 'degree_country_id' => $input['degree_country_id' . $key], 'degree_speciality' => $input['degree_speciality' . $key], 'degree_institution' => $input['degree_institution' . $key], 'degree_graduation_year' => $input['degree_graduation_year' . $key], 'degree_score' => $input['degree_score' . $key]];
         if (is_numeric($key) && $key > 0) {
             $ids[] = $key;
             RegistrationDegree::where('id', $key)->update($data);
         } else {
             $extra_degrees[] = $data;
         }
     }
     if (!empty($extra_degrees)) {
         foreach ($extra_degrees as $extra_degree) {
             $degree = RegistrationDegree::create($extra_degree);
             $ids[] = $degree->id;
         }
     }
     RegistrationDegree::where('registration_id', $registration_id)->whereNotIn('id', $ids)->delete();
 }
Exemple #2
0
 public function saveExtraDegrees($input, $registration_id)
 {
     $extra_degrees_keys = [];
     foreach ($input as $key => $value) {
         if (count($parts = explode('degree_name', $key)) > 1) {
             $extra_degrees_keys[] = $parts[1];
         }
     }
     $extra_degrees = [];
     foreach ($extra_degrees_keys as $key) {
         $extra_degrees[] = ['registration_id' => $registration_id, 'degree_name' => $input['degree_name' . $key], 'degree_country_id' => $input['degree_country_id' . $key], 'degree_speciality' => $input['degree_speciality' . $key], 'degree_institution' => $input['degree_institution' . $key], 'degree_graduation_year' => $input['degree_graduation_year' . $key], 'degree_score' => $input['degree_score' . $key]];
     }
     if (!empty($extra_degrees)) {
         RegistrationDegree::insert($extra_degrees);
     }
 }