https://github.com/wearebraid/carbon-availability
A Carbon utility useful for sorting out availability and producing calendly-like results.
https://github.com/wearebraid/carbon-availability
Last synced: 11 months ago
JSON representation
A Carbon utility useful for sorting out availability and producing calendly-like results.
- Host: GitHub
- URL: https://github.com/wearebraid/carbon-availability
- Owner: wearebraid
- License: mit
- Created: 2019-10-31T21:42:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-08T22:29:42.000Z (over 1 year ago)
- Last Synced: 2025-05-31T19:33:57.460Z (about 1 year ago)
- Language: PHP
- Size: 39.1 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CarbonAvailability
[](https://travis-ci.com/wearebraid/carbon-availability)
Given some available times and some unavailable times how do you determine what
time slots you can schedule an event of a certain duration (think something like
[calendly](https://calendly.com/))? Well – it's surprisingly hard – unless
you're using this.
```php
use Braid\CarbonAvailability;
/**
* [==========] | Available time blocks
* [========] |
* [==========] | ______________________
* [xxxxxxx] | Booked time blocks
* [x] | ______________________
* [==========] [====] [=] | Merged availability
* | | | | | | | | Available sessions
*/
$availability = [
['2019-01-01 09:00:00', '2019-01-01 10:00:00'],
['2019-01-01 10:15:00', '2019-01-01 11:00:00'],
['2019-01-01 11:00:00', '2019-01-01 12:00:00']
];
$booked = [
['2019-01-01 10:45:00', '2019-01-01 11:30:00'],
['2019-01-01 11:50:00', '2019-01-01 11:55:00']
];
$availability = new CarbonAvailability($availability, $booked);
$startTimes = $availability->session('15 minutes');
/* Returns the following Carbon\Carbon date times (2019-01-01):
09:00
09:15
09:30
09:45
10:15
10:30
11:30
*/
```
## Installation
```sh
composer require wearebraid/carbon-availability
```