Skip to content

Commit

Permalink
inject component instead of using this keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
mokhosh committed Sep 29, 2024
1 parent 8b3a3ef commit e65cccc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/FilamentJalaliServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Mokhosh\FilamentJalali;

use Filament\Forms\Components\DateTimePicker;
use Filament\Infolists\Components\Component;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Support\Assets\AlpineComponent;
Expand Down Expand Up @@ -78,16 +79,15 @@ public function packageBooted(): void

TextEntry::macro('jalaliDate', function (?string $format = null, ?string $timezone = null) {
$format ??= Infolist::$defaultDateDisplayFormat;
$timezone ??= $this->getTimezone();

$this->formatStateUsing(static function ($state) use ($format, $timezone): ?string {
$this->formatStateUsing(static function (Component $component, $state) use ($format, $timezone): ?string {
if (blank($state)) {
return null;
}

return CalendarUtils::convertNumbers(
Jalalian::fromCarbon(
Carbon::parse($state)->setTimezone($timezone)
Carbon::parse($state)->setTimezone($timezone ?? $component->getTimezone())
)->format($format),
! App::isLocale('fa')
);
Expand Down

0 comments on commit e65cccc

Please sign in to comment.