Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TappNetwork/filament-timezone-field
https://github.com/TappNetwork/filament-timezone-field
hacktoberfest
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/TappNetwork/filament-timezone-field
- Owner: TappNetwork
- Created: 2022-05-05T21:47:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-04T17:56:47.000Z (about 1 month ago)
- Last Synced: 2024-05-04T18:42:06.825Z (about 1 month ago)
- Topics: hacktoberfest
- Language: PHP
- Homepage:
- Size: 406 KB
- Stars: 33
- Watchers: 5
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Lists
- awesome-filament - TappNetwork/filament-timezone-field - A Timezone field for FilamentPHP. (Fields)
README
# Filament Timezone Field
A timezone select field for Laravel Filament.
## Installation
```bash
composer require tapp/filament-timezone-field:"^3.0"
```> **Note**
> For **Filament 2.x** check the **[2.x](https://github.com/TappNetwork/filament-timezone-field/tree/2.x)** branch## Usage
### Form Field
Add to your Filament resource:
```php
use Tapp\FilamentTimezoneField\Forms\Components\TimezoneSelect;public static function form(Form $form): Form
{
return $form
->schema([
// ...
TimezoneSelect::make('timezone'),
// ...
]);
}
```#### Appareance
![Filament Timezone Field](https://raw.githubusercontent.com/TappNetwork/filament-timezone-field/main/docs/filament-timezone-field.png)
#### Options
To use GMT instead of UTC (default is UTC), add the `->timezoneType('GMT')` method:
```php
use Tapp\FilamentTimezoneField\Forms\Components\TimezoneSelect;public static function form(Form $form): Form
{
return $form
->schema([
// ...
TimezoneSelect::make('timezone')
->timezoneType('GMT'),
// ...
]);
}
```All [Filament select field](https://filamentphp.com/docs/2.x/forms/fields#select) methods are available to use:
```php
use Tapp\FilamentTimezoneField\Forms\Components\TimezoneSelect;public static function form(Form $form): Form
{
return $form
->schema([
// ...
TimezoneSelect::make('timezone')
->searchable()
->required(),
// ...
]);
}
```### Table Column
```php
use Tapp\FilamentTimezoneField\Tables\Columns\TimezoneColumn;public static function table(Table $table): Table
{
return $table
->columns([
//...
TimezoneColumn::make('timezone')
->timezoneType('GMT')
->formattedOffsetAndTimezone(),
])
// ...
}
```#### Options
| Method | Description |
| --- | --- |
| ->formattedTimezone() | Show formatted timezone name |
| ->formattedOffsetAndTimezone() | Show formatted offset and timezone name |
| ->timezoneType('GMT') | Use GMT instead of UTC |### Table Filter
```php
use Tapp\FilamentTimezoneField\Tables\Filters\TimezoneSelectFilter;public static function table(Table $table): Table
{
return $table
//...
->filters([
TimezoneSelectFilter::make('timezone'),
// ...
])
}
```