ldc-le-gaulois-pro/app/Lib/CompleteSitemapWith.php
2023-11-06 11:01:02 +00:00

37 lines
1.2 KiB
PHP

<?php
namespace App\Lib;
use App\Enums\Advices\AdviceTypeEnum;
use App\Models\Advice;
use App\Models\Product;
use LDC\SitemapGenerator\Lib\Sitemap;
class CompleteSitemapWith
{
/**
* Use this method to append a list of links to the sitemap
*
* * Please call $sitemap->mergeUrls to append url for any specific route name.
*
* @param \LDC\SitemapGenerator\Lib\Sitemap $sitemap
* @return void
*/
public static function append(Sitemap $sitemap): void
{
// * Ajouts des éléments qui sont affichés en random
$sitemap->mergeUrls(Product::query()->where('status', true)->pluck('slug')->transform(function (string $slug) {
return \route('fo.product.show', $slug);
}));
$sitemap->mergeUrls(Advice::query()
->where('status', true)->where('type', AdviceTypeEnum::recipes)
->pluck('slug')->transform(function (string $slug) {
return \route('fo.recipes.show', $slug);
}));
$sitemap->mergeUrls(Advice::query()
->where('status', true)->where('type', AdviceTypeEnum::tips)
->pluck('slug')->transform(function (string $slug) {
return \route('fo.tips.show', $slug);
}));
}
}