mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
2.x - databases
This commit is contained in:
38
app/Web/Traits/HasWidgets.php
Normal file
38
app/Web/Traits/HasWidgets.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Web\Traits;
|
||||
|
||||
use Illuminate\View\ComponentAttributeBag;
|
||||
|
||||
trait HasWidgets
|
||||
{
|
||||
protected ?string $live = '5s';
|
||||
|
||||
protected array $extraAttributes = [];
|
||||
|
||||
protected function getExtraAttributes(): array
|
||||
{
|
||||
$attributes = $this->extraAttributes;
|
||||
|
||||
if ($this->getLive()) {
|
||||
$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;
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user