ldc-sitemap-generator/tests/Fixtures/Article.php

33 lines
712 B
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Uwil\SitemapGenerator\Tests\Fixtures;
use Illuminate\Database\Eloquent\Model;
use Spatie\Sitemap\Tags\Url;
use Uwil\SitemapGenerator\Contracts\Sitemapable;
/**
* @property int $id
* @property string $slug
*/
class Article extends Model implements Sitemapable
{
/** @var list<string> */
protected $guarded = [];
#[\Override]
public function getLocalizedUrl(string $locale): string
{
return "http://localhost/{$locale}/articles/{$this->slug}";
}
/** @return Url|string|string[] */
#[\Override]
public function toSitemapTag(): Url | string | array
{
return $this->getLocalizedUrl(app()->getLocale());
}
}