ldc-sitemap-generator/tests/Fixtures/Product.php
Jérémy Munsch 4e8c58d5f9
refactor: refactoring et ajout de tests, la dependance pour traduire les routes est vraiment optionnelle.
- Ajout de jobs de lint, test, ci
- Refactoring de code
- montée de version sur laravel 13 uniquement et php8.5
2026-10-15 10:18:25 +02:00

47 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Uwil\SitemapGenerator\Tests\Fixtures;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Sitemap\Tags\Url;
use Uwil\SitemapGenerator\Contracts\Sitemapable;
/**
* @property int $id
* @property string $slug
* @property bool $published
* @property int|null $range_id
* @property-read Range|null $range
*/
class Product extends Model implements Sitemapable
{
/** @var list<string> */
protected $guarded = [];
/** @var array<string, string> */
protected $casts = [
'published' => 'boolean',
];
/** @return BelongsTo<Range, $this> */
public function range(): BelongsTo
{
return $this->belongsTo(Range::class);
}
#[\Override]
public function getLocalizedUrl(string $locale): string
{
return "http://localhost/{$locale}/products/{$this->slug}";
}
/** @return Url|string|string[] */
#[\Override]
public function toSitemapTag(): Url | string | array
{
return $this->getLocalizedUrl(app()->getLocale());
}
}