PHP code example of romegasoftware / availability

1. Go to this page and download the library: Download romegasoftware/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/ */

    

romegasoftware / availability example snippets


$item->availabilityRules()->create([
    'type' => 'months_of_year',
    'config' => ['months' => [7]],
    'effect' => 'allow',
    'priority' => 10,
]);

$engine = app(\RomegaSoftware\Availability\Support\AvailabilityEngine::class);

if ($engine->isAvailable($item, now())) {
    // accept the booking
}

config(['availability.inventory_gate' => [
    'resolver' => function (AvailabilitySubject $subject, CarbonInterface $moment, array $ruleConfig): int {
        return $subject->currentStock();
    },
]]);
bash
php artisan vendor:publish --tag=availability-config
php artisan vendor:publish --tag=availability-migrations