adrema/app/View/Page/Layout.php

60 lines
2.1 KiB
PHP
Raw Normal View History

2024-10-13 21:00:47 +02:00
<?php
namespace App\View\Page;
use Illuminate\View\Component;
class Layout extends Component
{
2024-12-06 16:54:32 +01:00
public function __construct(public string $pageClass = '', public string $title = '', public string $menu = '')
2024-10-13 21:00:47 +02:00
{
2024-10-25 00:51:07 +02:00
session()->put('title', $title);
2024-12-06 16:54:32 +01:00
session()->put('menu', $menu);
2024-10-13 21:00:47 +02:00
}
public function userName(): string
{
return auth()->user()->firstname . ' ' . auth()->user()->lastname;
}
public function userAvatar(): string
{
return auth()->user()->getGravatarUrl();
}
public function render()
{
return <<<'HTML'
2024-10-20 21:23:47 +02:00
<div class="grow flex flex-col" @refresh-page.window="$wire.$refresh">
2024-10-13 21:00:47 +02:00
<div class="grow bg-gray-900 flex flex-col duration-300 navbar:ml-60">
2024-10-25 00:46:03 +02:00
<x-page::header :title="$title">
2024-10-13 21:00:47 +02:00
<x-slot:beforeTitle>
2024-10-24 23:05:12 +02:00
<a href="#" class="lg:hidden" wire:click.prevent="dispatch('toggle-sidebar')">
2024-10-13 21:00:47 +02:00
<x-ui::sprite src="menu" class="text-gray-100 w-5 h-5"></x-ui::sprite>
</a>
</x-slot:beforeTitle>
<x-slot:toolbar>
{{ $toolbar ?? ''}}
</x-slot:toolbar>
<x-slot:right>
{{ $right ?? '' }}
<div class="flex items-center space-x-2">
<div class="rounded-full overflow-hidden border-2 border-solid border-gray-300">
<img src="{{ $userAvatar() }}" class="w-8 h-8 object-cover" />
</div>
<div class="text-gray-300"">{{ $userName() }}</div>
</div>
</x-slot:right>
</x-page::header>
<div class="grow flex flex-col {{$pageClass}}">
{{ $slot }}
</div>
</div>
<livewire:page.sidebar :mobile="true" />
</div>
HTML;
}
}