PHP code example of wearebraid / carbon-availability

1. Go to this page and download the library: Download wearebraid/carbon-availability library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wearebraid / carbon-availability example snippets



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
*/