Boy132 885e03ee06
Alert banners (#892)
* add alert banner

* replace old server conflict banner with alert banner

* improve color and icon size

* add alert for websocket errors

* update file loading error to alert banner

* remove old events

* add back `console-status` event

* move @php block under @isset

* remove phpstan ignore

so I'm not getting force choked
2025-01-15 18:23:09 +01:00

42 lines
889 B
PHP

<?php
namespace App\Livewire;
use Filament\Notifications\Concerns;
use Filament\Support\Concerns\EvaluatesClosures;
use Illuminate\Contracts\Support\Arrayable;
final class AlertBanner implements Arrayable
{
use Concerns\HasBody;
use Concerns\HasIcon;
use Concerns\HasStatus;
use Concerns\HasTitle;
use EvaluatesClosures;
public static function make(): static
{
return new self();
}
public function toArray(): array
{
return [
'title' => $this->getTitle(),
'body' => $this->getBody(),
'status' => $this->getStatus(),
'icon' => $this->getIcon(),
];
}
public function send(): static
{
$alerts = session()->get('alert-banners', []);
$alerts[] = $this->toArray();
session()->flash('alert-banners', $alerts);
return $this;
}
}