phase 9
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\CacheService;
|
||||
use App\Services\SitemapService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private SitemapService $sitemapService,
|
||||
private CacheService $cacheService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Generate and serve main sitemap
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
$xml = $this->cacheService->remember(
|
||||
'sitemap:main',
|
||||
3600, // 1 hour cache
|
||||
fn() => $this->sitemapService->generateSitemap()
|
||||
);
|
||||
|
||||
return response($xml, 200)
|
||||
->header('Content-Type', 'application/xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and serve sitemap index
|
||||
*/
|
||||
public function sitemapIndex(): Response
|
||||
{
|
||||
$xml = $this->cacheService->remember(
|
||||
'sitemap:index',
|
||||
3600,
|
||||
fn() => $this->sitemapService->generateSitemapIndex()
|
||||
);
|
||||
|
||||
return response($xml, 200)
|
||||
->header('Content-Type', 'application/xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and serve main sitemap (static pages)
|
||||
*/
|
||||
public function mainSitemap(): Response
|
||||
{
|
||||
$xml = $this->cacheService->remember(
|
||||
'sitemap:main-pages',
|
||||
3600,
|
||||
fn() => $this->sitemapService->generateMainSitemap()
|
||||
);
|
||||
|
||||
return response($xml, 200)
|
||||
->header('Content-Type', 'application/xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and serve jobs sitemap
|
||||
*/
|
||||
public function jobsSitemap(): Response
|
||||
{
|
||||
$xml = $this->cacheService->remember(
|
||||
'sitemap:jobs',
|
||||
1800, // 30 minutes cache (jobs change more frequently)
|
||||
fn() => $this->sitemapService->generateJobsSitemap()
|
||||
);
|
||||
|
||||
return response($xml, 200)
|
||||
->header('Content-Type', 'application/xml');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user