- Ajout de jobs de lint, test, ci - Refactoring de code - montée de version sur laravel 13 uniquement et php8.5
47 lines
1.1 KiB
PHP
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());
|
|
}
|
|
}
|