zedmagdy/filament-business-hours
composer require zedmagdy/filament-business-hours in your Laravel project.PanelProvider with a timezone (e.g., 'Asia/Riyadh').json column (e.g., business_hours) to your model’s table.HasBusinessHours trait and cast the column as array in your model.Add a BusinessHoursField to a Filament form for a model (e.g., Branch):
BusinessHoursField::make('business_hours')
->columnSpanFull();
This renders a UI for defining daily business hours (e.g., 9 AM–5 PM) with timezone support.
CRUD Integration:
BusinessHoursField in Filament forms for editing/creating records.BusinessHoursColumn:
BusinessHoursColumn::make('business_hours')
->formatStateUsing(fn ($state) => $state['timezone'] ?? 'UTC');
Validation:
required|business_hours).Timezone Handling:
->defaultTimezone('America/New_York')
Exceptions:
->allowExceptions()
saving/saved events to log changes to business hours.public function getBusinessHoursAttribute($value) {
return json_decode($value, true);
}
JSON Column Quirks:
setBusinessHours()).Timezone Mismatches:
Exceptions Overlap:
$this->validateBusinessHoursExceptions();
Caching:
null or malformed. Use dd($model->business_hours) to inspect.php artisan filament:cache:clear) if the field renders incorrectly.Asia/Riyadh).Custom Fields:
BusinessHoursField to add features (e.g., recurring exceptions):
class CustomBusinessHoursField extends BusinessHoursField {
protected function getExtraAttributes(): array {
return ['recurring' => true];
}
}
Validation Rules:
public function validateBusinessHours($attribute, $value, $fail) {
// Custom logic
}
Table Actions:
Tables\Actions\Action::make('copyHours')
->action(function (Branch $record) {
// Logic to duplicate hours
});
How can I help you explore Laravel packages today?