Esempio n. 1
0
 public function addHigherInstDetails()
 {
     $client = (object) Input::all();
     $db = HigherInst::where('user_id', '=', $client->user_id)->first();
     $appData = ApplicationData::find(Input::all()['user_id']);
     $form_comp_data = FormCompleteData::find(Input::all()['user_id']);
     if (is_null($db)) {
         $db = new HigherInst();
         foreach ($client as $key => $value) {
             if (is_array($value)) {
                 $db->{$key} = $value['value'];
             } else {
                 $db->{$key} = $value;
             }
         }
         $db->save();
         $appData->app_progress = 20 + $appData->app_progress;
         $appData->save();
         $form_comp_data->higher_institution_completed = "1";
         $form_comp_data->save();
         return Response::json(array('warning' => 'Adding new stuff'));
     } else {
         foreach ($client as $key => $value) {
             if (is_array($value)) {
                 $db->{$key} = $value['value'];
             } else {
                 $db->{$key} = $value;
             }
         }
         $db->save();
         return Response::json(array('Warning' => 'Updating old stuff'));
     }
 }