input('url'); // check if the url is valid URL if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) { return response()->json([ 'error' => 'Missing required parameter `url`' ], 400); } $depth = $request->input('depth', 3); // default depth is 3 if not provided $crawlerController = new WebCrawlController(); $isAlreadyDone = $crawlerController->getOne($url); if(!$isAlreadyDone){ $crawlerController->crawlWebsite($url, $depth); } else { return response()->json([ 'error' => 'This URL has already been crawled', 'data' => $isAlreadyDone ], 400); } }); // Route::post('/crawl/{id}', function (String $id, Request $request, Response $response) { // $id = $request->input('id'); // $crawlerController = new WebCrawlController(); // if(!$crawlerController->destroy($id)) { // return response()->json([ // 'error' => 'Url Not Found', // ], 404); // } else { // return response()->json([ // 'success' => 'This URL has been deleted', // ], 200); // } // });