public function getTaskList(Request $request) { $taskCheck = TaskList::all(); foreach ($taskCheck as $task) { $date = strtotime($task->date . ' ' . $task->time); $date2 = date("Y-m-d h:i:s"); $date1 = strtotime($date2); if ($date1 > $date) { if ($task->status == "Remaining") { $task->status = "Late"; $task->update(); } } } $userID = $request->input('id'); $mode = $request->input('mode'); $taskList = User::with("taskList.plant.plot", "taskList.activityType", "taskList.ownerTask")->where("id", "=", $userID)->get(); $taskSort = array(); $i = 0; foreach ($taskList[0]->taskList as $task) { if ($task->status != "Done" && $task->status != "Late done" || $mode == "profile") { $taskSort[$i] = $task; $i++; } } return $taskSort; // }