Loheide-eu-mitarbeiterplatt.../vendor/filament/widgets/src/StatsOverviewWidget/Stat.php
Friederich Loheide 9c0f8de791
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Phase 0: Fundament für Inhaus
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 20:35:30 +00:00

187 lines
4.3 KiB
PHP

<?php
namespace Filament\Widgets\StatsOverviewWidget;
use BackedEnum;
use Closure;
use Filament\Schemas\Components\Component;
use Filament\Schemas\Components\Concerns\CanOpenUrl;
use Filament\Schemas\Components\Concerns\HasDescription;
use Filament\Schemas\Components\Concerns\HasLabel;
use Filament\Support\Concerns\HasColor;
use Filament\Support\Concerns\HasPlaceholder;
use Filament\Support\Enums\IconPosition;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Htmlable;
class Stat extends Component
{
use CanOpenUrl;
use HasColor;
use HasDescription;
use HasLabel;
use HasPlaceholder;
protected string $view = 'filament-widgets::stats-overview-widget.stat';
/**
* @var array<float> | null
*/
protected ?array $chart = null;
/**
* @var string | array<string> | null
*/
protected string | array | null $chartColor = null;
protected string | BackedEnum | null $icon = null;
protected string | BackedEnum | null $descriptionIcon = null;
protected IconPosition | string | null $descriptionIconPosition = null;
/**
* @var string | array<string> | null
*/
protected string | array | null $descriptionColor = null;
/**
* @var scalar | Htmlable | Closure | null
*/
protected $value;
/**
* @param scalar | Htmlable | Closure | null $value
*/
final public function __construct(string | Htmlable $label, $value)
{
$this->label($label);
$this->value($value);
}
/**
* @param scalar | Htmlable | Closure | null $value
*/
public static function make(string | Htmlable $label, $value): static
{
$static = app(static::class, ['label' => $label, 'value' => $value]);
$static->configure();
return $static;
}
/**
* @param string | array<string> | null $color
*/
public function chartColor(string | array | null $color): static
{
$this->chartColor = $color;
return $this;
}
public function icon(string | BackedEnum | null $icon): static
{
$this->icon = $icon;
return $this;
}
/**
* @param string | array<string> | null $color
*/
public function descriptionColor(string | array | null $color): static
{
$this->descriptionColor = $color;
return $this;
}
public function descriptionIcon(string | BackedEnum | null $icon, IconPosition | string | null $position = null): static
{
$this->descriptionIcon = $icon;
$this->descriptionIconPosition = $position;
return $this;
}
/**
* @param array<float> | Arrayable | null $chart
*/
public function chart(array | Arrayable | null $chart): static
{
if (is_null($chart)) {
return $this;
}
if ($chart instanceof Arrayable) {
$chart = $chart->toArray();
}
$this->chart = $chart;
return $this;
}
/**
* @param scalar | Htmlable | Closure | null $value
*/
public function value($value): static
{
$this->value = $value;
return $this;
}
/**
* @return array<float> | null
*/
public function getChart(): ?array
{
return $this->chart;
}
/**
* @return string | array<string> | null
*/
public function getChartColor(): string | array | null
{
return $this->chartColor ?? $this->getColor();
}
public function getIcon(): string | BackedEnum | Htmlable | null
{
return $this->icon;
}
/**
* @return string | array<string> | null
*/
public function getDescriptionColor(): string | array | null
{
return $this->descriptionColor ?? $this->getColor();
}
public function getDescriptionIcon(): string | BackedEnum | Htmlable | null
{
return $this->descriptionIcon;
}
public function getDescriptionIconPosition(): IconPosition | string
{
return $this->descriptionIconPosition ?? IconPosition::After;
}
/**
* @return scalar | Htmlable | null
*/
public function getValue(): mixed
{
return $this->evaluate($this->value);
}
public function generateChartDataChecksum(): string
{
return md5(json_encode($this->getChart()));
}
}