adrema/modules/Dashboard/Components/DashboardComponent.php

33 lines
910 B
PHP

<?php
namespace Modules\Dashboard\Components;
use Livewire\Component;
use Modules\Dashboard\DashboardFactory;
class DashboardComponent extends Component
{
private array $blocks = [];
public function mount(DashboardFactory $factory): void
{
$this->blocks = $factory->load();
}
public function render(): string
{
return <<<'HTML'
<x-page::layout title="Dashboard" menu="dashboard">
<div class="gap-6 md:grid-cols-2 xl:grid-cols-4 grid p-6">
@foreach($this->blocks as $block)
<x-ui::box title="{{$block->title()}}" :second="true">
<livewire:dynamic-component is="{{ get_class($block) }}" lazy></livewire:dynamic-component>
</x-ui::box>
@endforeach
</div>
</x-page::layout>
HTML;
}
}