29 lines
624 B
PHP

<?php
namespace App\Filament\Components\Tables\Columns;
use Filament\Tables\Columns\TextColumn;
class DateTimeColumn extends TextColumn
{
protected function setUp(): void
{
parent::setUp();
$this->dateTime();
}
public function since(?string $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');
}
}