map(fn ($dependency) => [ 'id' => $dependency['id'], 'dependencies' => collect($dependency['dependencies']) ->map(fn ($dependency) => Purchase::$dependencies[$dependency]['id']) ->toArray(), ]) ->toArray(); return response()->json($dependencies); } public function check(): JsonResponse { request()->validate(([ 'steps' => ['required', new Steps()] ])); return response()->json([], 200); } }