40 lines
936 B
PHP
40 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\WebCrawlRequest;
|
|
use App\Services\WebCrawlerService;
|
|
|
|
class WebCrawlController extends Controller
|
|
{
|
|
protected $webCrawlerService;
|
|
|
|
public function __construct(WebCrawlerService $webCrawlerService)
|
|
{
|
|
$this->webCrawlerService = $webCrawlerService;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return $this->webCrawlerService->getAllCrawls();
|
|
}
|
|
|
|
public function crawlWebsite(WebCrawlRequest $request)
|
|
{
|
|
$url = $request->query('url');
|
|
$depth = $request->query('depth', 0);
|
|
$refresh = $request->query('refresh', false);
|
|
|
|
return $this->webCrawlerService->crawlWebsite($url, $depth, $refresh);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
return $this->webCrawlerService->deleteCrawl($id);
|
|
}
|
|
|
|
public function destroyAll()
|
|
{
|
|
return $this->webCrawlerService->deleteAllCrawls();
|
|
}
|
|
}
|