/**
  * Display the specified resource.
  *
  * @param $timeCardHoursWorkedId
  *
  * @return \Illuminate\Http\Response|\Illuminate\View\View
  */
 public function show($timeCardHoursWorkedId)
 {
     // set appGlobal.clientId to current view, otherwise 'if (appGlobal.clientId)' in TimeCard.js causes a js load failure.
     appGlobals::populateJsGlobalClient();
     // used for routing.
     appGlobals::setSessionVariableAppGlobalTimeCardTableName($timeCardHoursWorkedId);
     // get all task for a specific time_card.date.
     /* @noinspection PhpUndefinedMethodInspection */
     $tasks = Task::where('time_card_hours_worked_id', '=', $timeCardHoursWorkedId)->get()->sortBy('start_time');
     // derive total hours worked.
     $totalHoursWorked = 0;
     foreach ($tasks as $task) {
         $totalHoursWorked += $task->hours_worked;
     }
     // eager load task_type for each task.
     /* @noinspection PhpUndefinedMethodInspection */
     $tasks->load('taskType');
     // get time_card data.
     /* @noinspection PhpUndefinedMethodInspection */
     $timeCard = TimeCardHoursWorked::where('id', '=', $timeCardHoursWorkedId)->get();
     // check if $timeCardHoursWorkedId exists, if not return 404 message.
     if (count($timeCard) == 0) {
         abort(404, 'Your Task ID does not exist.');
     }
     // pass the data to the view.
     return view('pages.userTaskView')->with('tasks', $tasks)->with('timeCard', $timeCard)->with('timeCardHoursWorkedId', $timeCardHoursWorkedId)->with('totalHoursWorked', $totalHoursWorked);
 }
 /**
  * @param $timeCardId
  */
 private function setGlobals($timeCardId)
 {
     // set appGlobal.clientId to current view, otherwise 'if (appGlobal.clientId)' in TimeCard.js causes js load failure.
     appGlobals::populateJsGlobalClient();
     // set appGlobal.taskTypeUpdateURI for ajax update routing.
     appGlobals::populateJsGlobalTaskTypeUpdateURI();
     // set appGlobal.ttvTypeClearText when phpunit selenium testing, only.
     appGlobals::populateJsGlobalTtvTypeClearTextTrue();
     // correctly sets the back button if the $timeCardId has been passed, the back button is set, else not.
     if (is_null($timeCardId)) {
         session()->forget(appGlobals::getTaskTableName());
     } else {
         session()->set(appGlobals::getTaskTableName(), $timeCardId);
     }
 }