- How do I install label84/laravel-hours-helper in a Laravel project?
- Run `composer require label84/laravel-hours-helper` in your project root. The package auto-registers via Laravel’s service provider discovery, so no additional configuration is needed.
- What Laravel versions does this package support?
- The package supports Laravel 11, 12, and 13. Check the [README](https://github.com/Label84/laravel-hours-helper) for version-specific release details.
- Can I generate time slots that span past midnight (e.g., 23:00 to 01:00)?
- Yes, the package handles past-midnight ranges seamlessly. For example, `HoursHelper::create('23:00', '01:00', 60)` will generate slots like 23:00, 00:00, and 01:00.
- How do I exclude specific time ranges from the generated slots?
- Pass an array of exclusion ranges to the `create()` method. For example, `HoursHelper::create('08:00', '11:00', 60, 'H:i', [['09:00', '09:59']])` will skip slots between 09:00 and 09:59.
- Does this package work with multi-day time intervals (e.g., weekly schedules)?
- Yes, you can generate slots across multiple days by specifying a start and end date with time. For example, `HoursHelper::create('2024-01-01 08:00', '2024-01-02 08:00', 60)` will include all hourly slots in that range.
- Can I customize the output format of the generated time slots?
- Absolutely. Use the fourth parameter of `create()` to specify a format string, like `'g:i A'` for 12-hour time (e.g., '11:00 AM') or `'Y-m-d H:i'` for full datetime strings.
- Will this package work efficiently for large time ranges (e.g., monthly or yearly slots)?
- For very large ranges, consider chunking or batching the generation to avoid memory issues. The package itself doesn’t enforce limits, but you may need to optimize how you process or store the results.
- How can I integrate this with Livewire or frontend frameworks like React/Vue?
- Return the generated Collection as JSON from a Laravel API endpoint or pass it directly to Blade templates. For Livewire, use `$this->emit()` to push slots to the frontend, or for React/Vue, fetch the JSON via an API call.
- Does this package support timezone handling beyond Laravel’s default timezone?
- The package uses Laravel’s default timezone (configured in `config/app.php`). For multi-timezone support, manually integrate Carbon’s `CarbonTimeZone` to generate slots in specific timezones before formatting.
- Are there alternatives to this package for generating time intervals in Laravel?
- Yes, you could use Carbon’s `copy()` and `addMinutes()` methods manually or leverage frontend libraries like FullCalendar for client-side generation. However, this package offers a Laravel-native, opinionated API tailored for server-side scheduling.