mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
- Introduced `config/seo.php` to centralize SEO settings. - Implemented `SeoTrait` for dynamic SEO management. - Added `SeoDataAttribute` to set SEO metadata at the class level. - Updated various views to integrate dynamic SEO handling. - Included fallback settings for titles, descriptions, images, and more.
32 lines
743 B
PHP
32 lines
743 B
PHP
<?php
|
|
namespace App\Traits;
|
|
|
|
use App\Attributes\SeoDataAttribute;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
trait SeoTrait
|
|
{
|
|
public function mountSeoTrait(): void
|
|
{
|
|
$this->setupSeo();
|
|
}
|
|
|
|
/**
|
|
* Setup SEO data from attributes and share it globally.
|
|
*/
|
|
protected function setupSeo(): void
|
|
{
|
|
$reflection = new \ReflectionClass($this);
|
|
$attributes = $reflection->getAttributes(SeoDataAttribute::class);
|
|
|
|
if (!empty($attributes)) {
|
|
$seoDataAttribute = $attributes[0]->newInstance();
|
|
$seoData = $seoDataAttribute->resolve();
|
|
} else {
|
|
$seoData = SeoDataAttribute::getData('default');
|
|
}
|
|
|
|
View::share('SEOData', $seoData);
|
|
}
|
|
}
|