Files
jobifygarden/app/Http/Controllers/Web/SitemapController.php
T

77 lines
1.9 KiB
PHP
Raw Normal View History

2026-04-04 02:14:57 +03:00
<?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');
}
}