Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Business Hours Laravel Package

zedmagdy/filament-business-hours

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modularity: The package is a Filament plugin, meaning it integrates cleanly into the Filament admin panel ecosystem without requiring a full rewrite of existing business logic. This aligns well with Laravel’s modular design and Filament’s plugin-based architecture.
  • Domain-Specific: Targets a niche but critical use case (business hours management) with timezone support, exceptions, and multi-slot configurations—ideal for SaaS, scheduling apps, or multi-location businesses.
  • Separation of Concerns: Encapsulates UI (Filament forms/tables), storage (JSON column), and business logic (traits) separately, reducing coupling with core application logic.

Integration Feasibility

  • Low Barrier to Entry: Requires minimal changes—just a JSON column, trait inclusion, and plugin registration. No complex migrations or ORM overrides.
  • Filament Dependency: Tightly coupled to Filament v2/3. If the app doesn’t use Filament, this package is non-starter unless wrapped in a custom solution.
  • Database Schema: Assumes JSON storage for business hours, which is flexible but may require schema adjustments if the app uses relational models for time slots (e.g., opens_at, closes_at columns).

Technical Risk

  • Filament Version Lock: Risk of breaking changes if Filament updates its internals (e.g., form/table component APIs). Monitor Filament’s roadmap.
  • JSON Storage Quirks: Storing business hours as JSON may complicate:
    • Database queries (e.g., filtering branches open at a given time).
    • Indexing (no native JSON indexes in all DBs; requires full-text or custom logic).
    • Serialization/deserialization edge cases (e.g., timezone handling during import/export).
  • Timezone Handling: Relies on PHP’s DateTime and Carbon for timezone logic. Ensure the app consistently uses a single timezone library (e.g., avoid mixing Carbon and DateTime).
  • Exceptions Logic: Custom exception handling (e.g., holidays) may require app-specific validation or additional UI for complex rules.

Key Questions

  1. Filament Adoption:

    • Is Filament already used in the admin panel? If not, is this package worth the Filament dependency?
    • What’s the upgrade path if Filament v4 drops support for this plugin?
  2. Data Model:

    • Does the app need to query business hours frequently (e.g., "find all branches open now")? If so, JSON storage may require denormalization or custom database views.
    • Are there existing models for time slots or exceptions that conflict with this package’s approach?
  3. Timezone Strategy:

    • How does the app handle timezones elsewhere? Will this package’s timezone selector conflict with existing logic (e.g., user preferences)?
    • Are business hours stored in UTC or local time? The package defaults to local time with timezone metadata.
  4. Edge Cases:

    • How should overlapping time slots or invalid configurations (e.g., opens_at > closes_at) be handled?
    • Are there compliance requirements (e.g., GDPR) for storing business hours in JSON vs. relational fields?
  5. Performance:

    • With many records, will JSON queries (e.g., WHERE business_hours->>'monday'->>'opens_at') impact performance?
    • Is there a need for real-time updates (e.g., WebSocket notifications when hours change)?

Integration Approach

Stack Fit

  • Best Fit:
    • Laravel apps using Filament v2/3 for admin panels, especially those managing locations, appointments, or scheduling (e.g., salons, retail, logistics).
    • Projects where business hours are configurable per entity (e.g., branches, agents) with exceptions.
  • Poor Fit:
    • Non-Filament Laravel apps (would require significant refactoring).
    • Apps with rigid business hour requirements (e.g., fixed 9–5) or heavy query needs on this data.

Migration Path

  1. Assessment Phase:
    • Audit existing business hour logic (e.g., hardcoded arrays, custom tables).
    • Identify models needing the HasBusinessHours trait (e.g., Branch, Store, Agent).
  2. Schema Migration:
    • Add JSON column to target tables (backward-compatible if nullable).
    • For apps with existing time slot tables, decide between:
      • Option A: Replace with JSON (simpler but less queryable).
      • Option B: Hybrid approach (keep relational data, use JSON for exceptions).
  3. Plugin Registration:
    • Register FilamentBusinessHoursPlugin in the Filament provider with the default timezone.
  4. UI Integration:
    • Replace or augment existing business hour forms/tables with BusinessHoursField and BusinessHourColumn.
    • Customize field options (e.g., disable exceptions for simple use cases).
  5. Data Migration:
    • Write a data seeder to convert existing business hour data to JSON format.
    • Example:
      Branch::query()->each(function ($branch) {
          $branch->business_hours = [
              'timezone' => 'America/New_York',
              'days' => [
                  'monday' => ['opens_at' => '09:00', 'closes_at' => '17:00'],
                  // ...
              ],
              'exceptions' => [] // populate as needed
          ];
          $branch->save();
      });
      

Compatibility

  • Laravel: Tested on Laravel 9/10 (assume compatibility with Filament’s supported versions).
  • Filament: Requires Filament v2 or v3. Check for breaking changes in Filament v4.
  • Database: Works with MySQL, PostgreSQL, SQLite (JSON support varies; test edge cases).
  • PHP: No strict version requirements, but assumes modern PHP (8.0+) for named arguments and attributes.

Sequencing

  1. Phase 1: Pilot with a non-critical model (e.g., TestLocation).
    • Test JSON storage, timezone handling, and exception logic.
    • Validate UI/UX in Filament.
  2. Phase 2: Roll out to core models (e.g., Branch, Agent).
    • Update queries to handle JSON data (e.g., use DB::select for complex filtering).
  3. Phase 3: Deprecate legacy business hour logic.
    • Add validation to reject non-JSON business hours.
  4. Phase 4: Optimize for performance.
    • Add database indexes if querying JSON fields (e.g., PostgreSQL JSONB).
    • Cache frequently accessed business hours (e.g., "branches open now").

Operational Impact

Maintenance

  • Pros:
    • Single Source of Truth: Business hours managed in one place (UI + JSON).
    • Filament Ecosystem: Leverages Filament’s built-in features (e.g., permissions, localization).
    • Low Code Maintenance: Changes to business hour logic (e.g., adding a new day) require no code updates—just UI configuration.
  • Cons:
    • Vendor Lock-in: Dependent on Filament and the package maintainer (low stars = untested long-term viability).
    • JSON Debugging: Harder to debug than relational data (e.g., "Why is this branch’s Monday slot invalid?").
    • Upgrade Risk: Filament or Laravel updates may break the plugin (monitor GitHub issues).

Support

  • Strengths:
    • Self-Documenting UI: Business hours are visible and editable in the admin panel, reducing support tickets for "What are your hours?" questions.
    • Timezone Awareness: Reduces timezone-related bugs (e.g., "Why is the branch showing as closed when it’s open?").
  • Challenges:
    • Complex Exceptions: Users may struggle with exception logic (e.g., "How do I add a holiday?"). Consider adding tooltips or a help section.
    • Data Corruption: Invalid JSON (e.g., malformed time slots) could break queries. Add validation:
      use ZEDMagdy\FilamentBusinessHours\Validation\BusinessHoursValidator;
      
      $request->validate([
          'business_hours' => ['required', new BusinessHoursValidator],
      ]);
      
    • Timezone Confusion: Users might mix timezones (e.g., set hours in UTC but expect local time). Enforce timezone consistency via validation.

Scaling

  • Performance:
    • Reads: JSON queries can be slow for large datasets. Mitigate with:
      • Database indexes (e.g., PostgreSQL JSONB operators).
      • Denormalized views (e.g., branches_open_now materialized view).
      • Caching (e.g., Redis for "branches open at timestamp X").
    • Writes: Minimal impact; JSON updates are atomic in modern databases.
  • Concurrency: Low risk unless many users edit business hours simultaneously. Consider optimistic locking:
    class Branch extends Model {
        use HasBusinessHours;
        public $timestamps = false; // or use `updated_at` for locking
    }
    
  • Multi-Tenancy: If the app is multi-tenant, ensure timezone settings are scoped per tenant (
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata