mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 19:01:37 +00:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Web\Components;
|
|
|
|
use App\Models\User;
|
|
use Filament\Pages\Page as BasePage;
|
|
use Illuminate\View\ComponentAttributeBag;
|
|
|
|
abstract class Page extends BasePage
|
|
{
|
|
protected static string $view = 'components.page';
|
|
|
|
protected ?string $live = '5s';
|
|
|
|
/**
|
|
* @var array<string, mixed>
|
|
*/
|
|
protected array $extraAttributes = [];
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function getExtraAttributes(): array
|
|
{
|
|
$attributes = $this->extraAttributes;
|
|
|
|
if (! in_array($this->getLive(), [null, '', '0'], true)) {
|
|
$attributes['wire:poll.'.$this->getLive()] = '$dispatch(\'$refresh\')';
|
|
}
|
|
|
|
return $attributes;
|
|
}
|
|
|
|
public function getExtraAttributesBag(): ComponentAttributeBag
|
|
{
|
|
return new ComponentAttributeBag($this->getExtraAttributes());
|
|
}
|
|
|
|
public function getLive(): ?string
|
|
{
|
|
return $this->live;
|
|
}
|
|
|
|
/**
|
|
* @return array<int, mixed>
|
|
*/
|
|
public function getWidgets(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
protected function getUser(): User
|
|
{
|
|
/** @var User $user */
|
|
$user = auth()->user();
|
|
|
|
return $user;
|
|
}
|
|
}
|