Skip to content

Commit c69bfc7

Browse files
fix: changed formatting to all be done through the config
1 parent 5023f5a commit c69bfc7

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

README.md

+34-10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/gerenuk/filament-utc-dts/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/gerenuk/filament-utc-dts/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
66
[![Total Downloads](https://img.shields.io/packagist/dt/gerenuk/filament-utc-dts.svg?style=flat-square)](https://packagist.org/packages/gerenuk/filament-utc-dts)
77

8+
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
89

10+
## Version Compatibility
911

10-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
12+
| Plugin | Filament | Laravel | PHP |
13+
|--------|----------|---------|----------|
14+
| 1.x | 3.x | 10.x | 8.x |
15+
| 1.x | 3.x | 11.x | 8.2\|8.3 |
1116

1217
## Installation
1318

@@ -17,13 +22,6 @@ You can install the package via composer:
1722
composer require gerenuk/filament-utc-dts
1823
```
1924

20-
You can publish and run the migrations with:
21-
22-
```bash
23-
php artisan vendor:publish --tag="filament-utc-dts-migrations"
24-
php artisan migrate
25-
```
26-
2725
You can publish the config file with:
2826

2927
```bash
@@ -40,14 +38,40 @@ This is the contents of the published config file:
4038

4139
```php
4240
return [
41+
/*
42+
* Whether a border should be shown.
43+
*/
44+
'show_border' => false,
45+
46+
/*
47+
* The format of the datestamp.
48+
*/
49+
'format' => 'd M Hi\Z',
4350
];
4451
```
4552

4653
## Usage
4754

55+
You first need to register the plugin with Filament. This can be done inside of your `PanelProvider`, e.g. `AdminPanelProvider`.
56+
4857
```php
49-
$filamentUtcDts = new Gerenuk\FilamentUtcDts();
50-
echo $filamentUtcDts->echoPhrase('Hello, Gerenuk!');
58+
<?php
59+
60+
namespace App\Providers\Filament;
61+
62+
use Filament\Panel;
63+
use Filament\PanelProvider;
64+
use Gerenuk\FilamentUtcDts\FilamentUtcDtsPlugin;
65+
66+
class AdminPanelProvider extends PanelProvider
67+
{
68+
public function panel(Panel $panel): Panel
69+
{
70+
return $panel
71+
// ...
72+
->plugin(FilamentUtcDtsPlugin::make());
73+
}
74+
}
5175
```
5276

5377
## Testing

config/filament-utc-dts.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
'show_border' => false,
99

1010
/*
11-
* Whether a date should be shown alongside the time.
11+
* The format of the datestamp.
1212
*/
13-
'show_date' => false,
14-
15-
/*
16-
* The format of the date.
17-
*/
18-
'date_format' => 'Y-m-d',
13+
'format' => 'd M Hi\Z',
1914
];

resources/views/badge.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div @class([
22
'hidden sm:flex items-center h-9 px-3 text-sm font-medium
3-
rounded-lg text-gray-900',
3+
rounded-lg shadow-sm text-gray-900',
44
'ring-1 ring-inset ring-gray-200' => $showBorder,
55
])>{{ $datestamp }}</div>

src/FilamentUtcDtsPlugin.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ public function getId(): string
1717
public function register(Panel $panel): void
1818
{
1919
$panel->renderHook('panels::global-search.before', function () {
20-
$timestamp = Carbon::now()->utc();
21-
$formattedTimestamp = config('filament-utc-dts.show_date') ? $timestamp->toDateTimeString() : $timestamp;
20+
$timestamp = Carbon::now()->utc()->format(config('filament-utc-dts.date_format'));
2221

2322
return View::make('filament-utc-dts::badge', [
2423
'showBorder' => config('filament-utc-dts.show_border'),
25-
'datestamp' => $formattedTimestamp,
24+
'datestamp' => $timestamp,
2625
]);
2726
});
2827
}

0 commit comments

Comments
 (0)