1, 'text' => 'Project Planning', 'start_date' => '2024-01-01', 'duration' => 5, 'progress' => 100, 'priority' => 'high', 'notes' => 'Initial project planning and requirements gathering', 'parent' => null ], [ 'id' => 2, 'text' => 'Design Phase', 'start_date' => '2024-01-06', 'duration' => 10, 'progress' => 60, 'priority' => 'medium', 'notes' => 'UI/UX design and wireframing', 'parent' => null ], [ 'id' => 3, 'text' => 'Development', 'start_date' => '2024-01-16', 'duration' => 15, 'progress' => 30, 'priority' => 'high', 'notes' => 'Core development work', 'parent' => null ], [ 'id' => 4, 'text' => 'Testing', 'start_date' => '2024-01-31', 'duration' => 7, 'progress' => 0, 'priority' => 'medium', 'notes' => 'Quality assurance and testing', 'parent' => null ], [ 'id' => 5, 'text' => 'Deployment', 'start_date' => '2024-02-07', 'duration' => 3, 'progress' => 0, 'priority' => 'critical', 'notes' => 'Production deployment and launch', 'parent' => null ], [ 'id' => 6, 'text' => 'Frontend Development', 'start_date' => '2024-01-16', 'duration' => 8, 'progress' => 40, 'priority' => 'high', 'notes' => 'Vue.js frontend development', 'parent' => 3 ], [ 'id' => 7, 'text' => 'Backend Development', 'start_date' => '2024-01-24', 'duration' => 7, 'progress' => 20, 'priority' => 'high', 'notes' => 'Laravel backend development', 'parent' => 3 ] ]; return response()->json([ 'success' => true, 'data' => $tasks, 'message' => 'Tasks retrieved successfully' ]); } /** * Store a newly created task */ public function store(Request $request): JsonResponse { $validator = Validator::make($request->all(), [ 'text' => 'required|string|max:255', 'start_date' => 'required|date', 'duration' => 'required|integer|min:1', 'priority' => 'required|in:low,medium,high,critical', 'notes' => 'nullable|string', 'parent' => 'nullable|integer' ]); if ($validator->fails()) { return response()->json([ 'success' => false, 'message' => 'Validation failed', 'errors' => $validator->errors() ], 422); } // In real app, save to database $task = [ 'id' => rand(1000, 9999), // Generate random ID for demo 'text' => $request->text, 'start_date' => $request->start_date, 'duration' => $request->duration, 'progress' => 0, 'priority' => $request->priority, 'notes' => $request->notes, 'parent' => $request->parent ]; return response()->json([ 'success' => true, 'data' => $task, 'message' => 'Task created successfully' ], 201); } /** * Display the specified task */ public function show(int $id): JsonResponse { // Sample task data - in real app, fetch from database $task = [ 'id' => $id, 'text' => 'Sample Task', 'start_date' => '2024-01-01', 'duration' => 5, 'progress' => 50, 'priority' => 'medium', 'notes' => 'This is a sample task', 'parent' => null ]; return response()->json([ 'success' => true, 'data' => $task, 'message' => 'Task retrieved successfully' ]); } /** * Update the specified task */ public function update(Request $request, int $id): JsonResponse { $validator = Validator::make($request->all(), [ 'text' => 'required|string|max:255', 'start_date' => 'required|date', 'duration' => 'required|integer|min:1', 'priority' => 'required|in:low,medium,high,critical', 'notes' => 'nullable|string', 'parent' => 'nullable|integer' ]); if ($validator->fails()) { return response()->json([ 'success' => false, 'message' => 'Validation failed', 'errors' => $validator->errors() ], 422); } // In real app, update in database $task = [ 'id' => $id, 'text' => $request->text, 'start_date' => $request->start_date, 'duration' => $request->duration, 'progress' => $request->progress ?? 0, 'priority' => $request->priority, 'notes' => $request->notes, 'parent' => $request->parent ]; return response()->json([ 'success' => true, 'data' => $task, 'message' => 'Task updated successfully' ]); } /** * Remove the specified task */ public function destroy(int $id): JsonResponse { // In real app, delete from database return response()->json([ 'success' => true, 'message' => 'Task deleted successfully' ]); } }