### Install Package with Composer Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Install the Filament Business Hours package using the `composer require` command after adding the repository to your composer.json. You will be prompted for authentication credentials. ```bash composer require andreia/filament-business-hours:"^4.0" ``` -------------------------------- ### Install Filament Business Hours Plugin Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Instructions to install the Filament Business Hours plugin using Composer, including configuring the composer.json repository and publishing migrations. ```bash # Add repository to composer.json { "repositories": [ { "type": "composer", "url": "https://filament-business-hours.composer.sh" } ] } # Install the package composer require andreia/filament-business-hours:"^4.0" # Publish and run migrations php artisan vendor:publish --tag="filament-business-hours-migrations" php artisan migrate # Optional: Publish config, views, and translations php artisan vendor:publish --tag="filament-business-hours-config" php artisan vendor:publish --tag="filament-business-hours-views" php artisan vendor:publish --tag="filament-business-hours-translations" ``` -------------------------------- ### Add Composer Repository Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Configure your composer.json file to include the Filament Business Hours package repository. This step is necessary before you can install the package using Composer. ```json { "repositories": [ { "type": "composer", "url": "https://filament-business-hours.composer.sh" } ] } ``` -------------------------------- ### Query Business Hours Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Demonstrates how to use the methods provided by the `HasBusinessHours` trait to check if a business is open, get opening times, and query specific date/time ranges. ```php $modelWithBusinessHours = Company::find($companyId); // Check if business is open $modelWithBusinessHours->isOpen(); // Get next opening time $nextOpen = $modelWithBusinessHours->nextOpen(); // Get current open range $range = $modelWithBusinessHours->currentOpenRange(); // Check specific date/time $isOpen = $modelWithBusinessHours->isOpen(now()->addDays(2)); ``` -------------------------------- ### Display Business Hours in Filament Infolists using PHP Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Utilizes the BusinessHoursEntry component to display formatted business hours, including timezone and exceptions, within Filament infolists and view pages. This snippet shows basic usage and an example with a section wrapper for better presentation. ```php schema([ Infolists\Components\TextEntry::make('name'), Infolists\Components\TextEntry::make('email'), // Basic business hours display BusinessHoursEntry::make('businessHours'), // With section wrapper for better presentation Infolists\Components\Section::make('Business Hours') ->description('Operating schedule for this location') ->icon('heroicon-o-clock') ->schema([ BusinessHoursEntry::make('businessHours') ->hiddenLabel() ->columnSpanFull(), ]), ]); } } ``` -------------------------------- ### BusinessHoursField within a Section Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Example of embedding the `BusinessHoursField` within a Filament `Section` component for better form organization and user experience. ```php use Andreia\FilamentBusinessHours\Forms\Components\BusinessHoursField; use Filament\Forms\Components\Section; Section::make('Business Hours') ->description('Control the availability of hours on each weekday') ->icon('heroicon-o-clock') ->schema([ BusinessHoursField::make('businessHours') ->allowExceptions(), ]), ``` -------------------------------- ### Publish and Run Migrations Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Publish the necessary migration files for the Filament Business Hours package and then run the migrations to set up the database tables. ```bash php artisan vendor:publish --tag="filament-business-hours-migrations" php artisan migrate ``` -------------------------------- ### Publish Configuration File Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Optionally, publish the configuration file for the Filament Business Hours package to customize its settings. ```bash php artisan vendor:publish --tag="filament-business-hours-config" ``` -------------------------------- ### Publish Views Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Optionally, publish the view files for the Filament Business Hours package if you need to customize their appearance. ```bash php artisan vendor:publish --tag="filament-business-hours-views" ``` -------------------------------- ### Query Business Hours using Model Trait Methods Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Shows how to use helper methods provided by the HasBusinessHours trait to query the business's opening status, next opening/closing times, and current open time ranges. ```php isOpen(); // Returns: true or false // Check if open at a specific date/time $isFutureOpen = $company->isOpen(now()->addDays(2)->setHour(10)); // Returns: true or false // Get next opening time $nextOpen = $company->nextOpen(); // Returns: Carbon instance (e.g., "2025-01-13 09:00:00") // Get next closing time $nextClose = $company->nextClose(); // Returns: Carbon instance (e.g., "2025-01-13 17:00:00") // Get current open time range $range = $company->currentOpenRange(); // Returns: Spatie\OpeningHours\TimeRange instance // Access full Spatie OpeningHours for advanced queries $openingHours = $company->openingHours; $forDay = $openingHours->forDay('monday'); // Returns: OpeningHoursForDay with time ranges ``` -------------------------------- ### Run Tests for Filament Business Hours Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md This command executes the test suite for the Filament Business Hours package using Composer. It's a standard way to ensure the package's functionality remains intact. ```bash composer test ``` -------------------------------- ### Enable Exceptions in Filament Business Hours Form Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md This snippet shows how to enable the exception setting functionality for the BusinessHoursField in a Filament form. It utilizes the `allowExceptions()` method to display a button for setting up exceptions, which are then saved in a Spatie-style format. ```php use Andreia\FilamentBusinessHours\Forms\Components\BusinessHoursField; $form->schema([ // ... BusinessHoursField::make('businessHours') ->allowExceptions(), ]), ``` -------------------------------- ### Publish Translations Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Publish the language files for the Filament Business Hours package to customize translations or add support for new languages. ```bash php artisan vendor:publish --tag="filament-business-hours-translations" ``` -------------------------------- ### Integrate HasBusinessHours Trait with Eloquent Model Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Demonstrates how to add the HasBusinessHours trait to an Eloquent model to enable business hours functionality, including a morphOne relationship and Spatie Opening Hours integration. ```php columns([ Tables\Columns\TextColumn::make('name') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('email') ->searchable(), // Business hours column with interactive day circles // Shows M T W T F S S with tooltips for each day's hours BusinessHoursColumn::make('businessHours'), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]); } } ``` -------------------------------- ### Add Business Hours Path to Theme Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Integrate the package's TailwindCSS classes into your custom Filament theme by adding the vendor directory path to your `theme.css` file. ```css /* ... */ @source '../../../../vendor/filament-handbook/filament-business-hours'; ``` -------------------------------- ### Configure Business Hours Exceptions in PHP Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Manages holidays, special hours, and recurring annual exceptions using a Spatie-style format. Exceptions are stored in the database and managed via a modal UI. This snippet demonstrates the structure for defining specific dates, closed days, recurring exceptions, and date ranges with labels. ```php ['09:00-12:00'], // Specific date closed all day '2025-07-04' => [], // Recurring annually (New Year's Day - closed) '01-01' => [], // Recurring annually (Christmas - modified hours) '12-25' => ['09:00-12:00'], // Date range with label (single day with description) '12-25 to 12-25' => [ 'hours' => [], 'data' => 'Holidays', ], // Date range with label (multi-day closure) '2025-06-25 to 2025-07-01' => [ 'hours' => [], 'data' => 'Closed for renovation', ], ]; // Enable exceptions in the form field BusinessHoursField::make('businessHours') ->allowExceptions(); ``` -------------------------------- ### Use BusinessHoursField in Filament Forms Source: https://github.com/andreia/filament-business-hours-docs/blob/main/README.md Integrate the `BusinessHoursField` into your Filament forms to allow users to manage business hours. The `allowExceptions()` method can be used to enable the management of exceptions to standard opening hours. ```php use Andreia\FilamentBusinessHours\Forms\Components\BusinessHoursField; BusinessHoursField::make('businessHours') ->allowExceptions(); ``` -------------------------------- ### Configure Filament Theme for Business Hours Plugin CSS in CSS Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Adds the plugin's TailwindCSS classes to your custom Filament theme for proper styling. This CSS snippet imports the base Filament theme and then includes the plugin's source files, ensuring correct visual rendering. ```css /* resources/css/filament/admin/theme.css */ @import '/vendor/filament/filament/resources/css/theme.css'; @config 'tailwind.config.js'; /* Add Business Hours plugin source */ @source '../../../../vendor/filament-handbook/filament-business-hours'; ``` -------------------------------- ### Add BusinessHoursField to Filament Form Source: https://context7.com/andreia/filament-business-hours-docs/llms.txt Illustrates how to integrate the BusinessHoursField component into a Filament resource form, including options for enabling exception management for holidays and special schedules. ```php schema([ Forms\Components\TextInput::make('name') ->required(), Forms\Components\TextInput::make('email') ->email(), // Basic business hours field BusinessHoursField::make('businessHours'), // With exceptions enabled (holidays, special hours) Forms\Components\Section::make('Business Hours') ->description('Control the availability of hours on each weekday') ->icon('heroicon-o-clock') ->schema([ BusinessHoursField::make('businessHours') ->allowExceptions(), ]), ]); } } ``` -------------------------------- ### Use BusinessHoursField in Forms Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Integrate the `BusinessHoursField` component into your Filament forms to allow users to manage business hours, with an option to enable exceptions. ```php use Andreia\FilamentBusinessHours\Forms\Components\BusinessHoursField; BusinessHoursField::make('businessHours') ->allowExceptions() ``` -------------------------------- ### Add HasBusinessHours Trait to Model Source: https://github.com/andreia/filament-business-hours-docs/blob/main/v4.md Incorporate the `HasBusinessHours` trait into your Eloquent model to enable business hours functionality, including relationships and helper methods. ```php use Andreia\FilamentBusinessHours\Concerns\HasBusinessHours; class Business extends Model { use HasBusinessHours; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.