adrema/app/View/Page/SettingLayout.php

44 lines
1.1 KiB
PHP

<?php
namespace App\View\Page;
use App\Setting\SettingFactory;
use Illuminate\View\Component;
class SettingLayout extends Component
{
public array $entries;
public function __construct(public string $active)
{
$this->entries = app(SettingFactory::class)->all()
->map(fn ($setting) => [
'url' => $setting->url(),
'is_active' => get_class($setting) === $active,
'title' => $setting->title(),
])->toArray();
session()->put('menu', 'setting');
}
public function render()
{
return <<<'HTML'
<x-page::layout :title="$active::title()">
<x-slot:right>
{{ $right ?? '' }}
</x-slot:right>
<x-slot:toolbar>
{{ $toolbar ?? '' }}
</x-slot:toolbar>
<div class="flex grow relative">
<x-ui::menulist :entries="$entries"></x-ui::menulist>
<div class="grow">
{{ $slot }}
</div>
</div>
</x-page::layout>
HTML;
}
}