/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(ProjectTemplate $template, $id, Request $request) { $taskList = ProjectTemplateTaskList::find($id); $position = $taskList->tasks->max('position') + 1; $task = $taskList->tasks()->create(['name' => $request->input('task'), 'position' => $position]); return $task; }
public function reorder(ProjectTemplate $template, $id, Request $request) { $taskList = ProjectTemplateTaskList::find($id); $i = 1; $return = ''; foreach ($request->input('item') as $task) { $return .= $task . " in Position " . $i . "; "; $task = ProjectTemplateTask::find($task); $task->position = $i; $task->save(); $i++; } return $return; }