zedmagdy / filament-business-hours
A filament package for managing business hours with timezone support and exceptions.
Package info
github.com/ZED-Magdy/filament-business-hours
pkg:composer/zedmagdy/filament-business-hours
v1.0.0
2026-04-02 20:56 UTC
Requires
- php: ^8.3
- filament/filament: ^4.3.1 || ^5.0
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
- spatie/opening-hours: ^4.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
A Filament plugin for managing business hours with timezone support, multiple time slots per day, and exception handling.
Installation
composer require zedmagdy/filament-business-hours
Setup
1. Register the Plugin
In your Filament panel provider:
use ZEDMagdy\FilamentBusinessHours\FilamentBusinessHoursPlugin; ->plugins([ FilamentBusinessHoursPlugin::make() ->timezone('Asia/Riyadh'), // optional ])
2. Add Database Columns
Add a JSON column to your model's table:
Schema::table('branches', function (Blueprint $table) { $table->json('business_hours')->nullable(); });
3. Configure Your Model
use ZEDMagdy\FilamentBusinessHours\Traits\HasBusinessHours; class Branch extends Model { use HasBusinessHours; protected function casts(): array { return [ 'business_hours' => 'array', ]; } }
Usage
Form Field
use ZEDMagdy\FilamentBusinessHours\Forms\Components\BusinessHoursField; BusinessHoursField::make('business_hours') ->timezone() // show timezone selector (default: true) ->allowExceptions() // show exceptions section (default: true) ->collapsible() // collapsible day sections (default: true) ->defaultTimezone('UTC') // default timezone for new records ->columnSpanFull()
Table Column
use ZEDMagdy\FilamentBusinessHours\Tables\Columns\BusinessHoursColumn; // Status badge (Open/Closed) BusinessHoursColumn::make('business_hours') ->statusMode() // Weekly schedule grid BusinessHoursColumn::make('business_hours') ->scheduleMode()
Infolist Entry
use ZEDMagdy\FilamentBusinessHours\Infolists\Components\BusinessHoursEntry; // Full schedule with exceptions BusinessHoursEntry::make('business_hours') ->fullMode() // Status badge only BusinessHoursEntry::make('business_hours') ->statusMode() // Compact single-line BusinessHoursEntry::make('business_hours') ->compactMode()
Model Methods
$branch = Branch::first(); $branch->isOpen(); // true/false (current time) $branch->isClosed(); // true/false $branch->isOpenOn('monday'); // true/false $branch->isClosedOn('sunday'); // true/false $branch->nextOpen(); // Carbon instance $branch->nextClose(); // Carbon instance $branch->getBusinessTimezone(); // string
Configuration
Publish the config file:
php artisan vendor:publish --tag="filament-business-hours-config"
License
MIT