Web_Crawler_API/app/Http/Controllers/WebCrawlController.php

41 lines
936 B
PHP
Raw Normal View History

2023-05-30 14:29:46 +00:00
<?php
namespace App\Http\Controllers;
use App\Http\Requests\WebCrawlRequest;
use App\Services\WebCrawlerService;
2023-05-30 14:29:46 +00:00
class WebCrawlController extends Controller
{
protected $webCrawlerService;
public function __construct(WebCrawlerService $webCrawlerService)
{
$this->webCrawlerService = $webCrawlerService;
}
2023-05-30 14:29:46 +00:00
public function index()
2023-05-30 17:19:53 +00:00
{
return $this->webCrawlerService->getAllCrawls();
2023-05-30 17:19:53 +00:00
}
public function crawlWebsite(WebCrawlRequest $request)
{
$url = $request->query('url');
2023-05-31 11:52:51 +00:00
$depth = $request->query('depth', 0);
2023-05-31 10:17:19 +00:00
$refresh = $request->query('refresh', false);
2023-05-30 17:19:53 +00:00
return $this->webCrawlerService->crawlWebsite($url, $depth, $refresh);
2023-05-30 14:29:46 +00:00
}
2023-05-30 17:19:53 +00:00
public function destroy($id)
2023-05-30 14:29:46 +00:00
{
return $this->webCrawlerService->deleteCrawl($id);
}
public function destroyAll()
{
return $this->webCrawlerService->deleteAllCrawls();
2023-05-30 14:29:46 +00:00
}
}