protected function getList() { if ($this->request->has('task')) { $taskId = $this->request->input('task'); /** @var Task $task */ $task = Task::findOrFail($taskId); $this->pageTitle = ' Submissions for ' . $task->name; $this->breadcrumbs = \Breadcrumbs::render('task-submissions', $task); return Submission::where('taskId', $taskId)->orderBy('createdAt', 'DESC'); } else { return Submission::orderBy('createdAt', 'DESC'); } }
/** * Remove the specified resource from storage. * * @param Request $request * @param User $user * * @return Response */ public function destroy(Request $request, User $user) { $this->requireUser($user); $toDoManager = new ToDoManager(); if ($request->has('taskId')) { $this->validate($request, ['taskId' => 'integer']); $taskId = $request->input('taskId'); /** @var Task $task */ $task = Task::findOrFail($taskId); $success = $toDoManager->removeTaskToDo($task, $user) > 0; } elseif ($request->has('stickerId')) { $this->validate($request, ['stickerId' => 'integer']); $stickerId = $request->input('stickerId'); /** @var Sticker $sticker */ $sticker = Sticker::findOrFail($stickerId); $success = $toDoManager->removeStickerToDo($sticker, $user) > 0; } else { throw new HttpException(400, "taskId or stickerId is required"); } return $this->response(['success' => $success]); }
protected function getInstance($id) { return Task::findOrFail($id); }