notCharles 6284c73edb wip
2025-04-24 20:02:20 -04:00

30 lines
648 B
PHP

<?php
namespace App\Filament\Components\Tables\Columns;
use Closure;
use Filament\Tables\Columns\TextColumn;
class DateTimeColumn extends TextColumn
{
protected function setUp(): void
{
parent::setUp();
$this->dateTime();
}
public function since(string|Closure|null $timezone = null): static
{
$this->formatStateUsing(fn ($state) => $state->diffForHumans());
$this->tooltip(fn ($state) => $state?->timezone($this->getTimezone()));
return $this;
}
public function getTimezone(): string
{
return auth()->user()->timezone ?? config('app.timezone', 'UTC');
}
}