/**
  * This method will fetch all the competences and period of work for a
  * specific person. This person will be the person that has the application
  * id that is entered by the visitor. The information will then be saved
  * in their corresponding arrays in the session array
  * @param Request $request
  * @return view
  */
 public function fetchData(Request $request)
 {
     $this->validate($request, ['appId' => 'required|max:2']);
     Session::forget('periodArray');
     Session::forget('competenceArray');
     Session::forget('listArray');
     DB::transaction(function () {
         $currentId = Req::get('appId');
         $competence_profile = \App\Competence_profile::where('application_id', $currentId)->get();
         foreach ($competence_profile as $profile) {
             $competence = \App\Competence::where('id', $profile->competence_id)->value('name');
             $competenceObj = new \App\CompetenceObj($competence, $profile->years_of_experience);
             Session::push('competenceArray', $competenceObj);
         }
         $periods = \App\Period::where('application_id', $currentId)->get();
         foreach ($periods as $period) {
             $periodObj = new \App\PeriodObj($period->from_date, $period->to_date);
             Session::push('periodArray', $periodObj);
         }
         $applications = \App\Application_form::where('id', $currentId)->get();
         foreach ($applications as $application) {
             $first_name = \App\User::where('id', $application->user_id)->value('first_name');
             $last_name = \App\User::where('id', $application->user_id)->value('last_name');
             $ssn = \App\User::where('id', $application->user_id)->value('ssn');
             $email = \App\User::where('id', $application->user_id)->value('email');
             $applicationDTO = new \App\ApplicationDTO($application->id, $first_name, $last_name, $ssn, $email, $application->date, $application->status);
             Session::push('listArray', $applicationDTO);
         }
     });
     return view('status_application');
 }