PHP code example of moonshiner / safe-queuing

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

    

moonshiner / safe-queuing example snippets


// config/app.php
'providers' => [
    // ...
    Moonshiner\SafeQueuing\SafeQueuingServiceProvider::class,
];

use Moonshiner\SafeQueuing\HasTimeslots;

//...

class Event extends Model
{
    use HasTimeslots;

public function timeslotStartDate(){
    return \Carbon\Carbon::now();
}
public function timeslotEndDate(){}
public function timeslotStartTime(){}
public function timeslotEndTime(){}
public function timeslotDuration(){}
public function timeslotBreak(){}
public function timeslotAvailableDays(){}
public function timeslotExcludedDates(){}
public function timeslotIncludedDates(){}
public function timeslotExcludedTimes(){}

$event = Event::first();

dd($event->timeslots());


$event = Event::first();

dd($event->reservations);

use Carbon\Carbon;
$event = Event::first();


// timeslots after some date
dd($event->timeslots()->findSlot(['start'=>Carbon::now(), 'end'=>Carbon::now()->addMinutes('30')]));

// only timeslots on a specific date
dd($event->timeslots()->onDay(Carbon::today()));

// timeslots after some date
dd($event->timeslots()->afterDate(Carbon::yesterday()));

// timeslots that end before given time
dd($event->timeslots()->beforeDate(Carbon::tomorrow()));

$event = Event::first();
$timeslot = $event->timeslots()->first();

$event->reservations()->create([
    'details' => 'Person specific data',
    'timeslot' => $timeslot
]);
bash
php artisan vendor:publish --provider="Moonshiner\SafeQueuing\SafeQueuingServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="Moonshiner\SafeQueuing\SafeQueuingServiceProvider" --tag="migrations"
php artisan migrate