PHP code example of vantage / period-queries

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

    

vantage / period-queries example snippets




use Illuminate\Database\Eloquent\Model;

class Event extends Model
{
    /**
     * The attributes that should be mutated to dates.
     */
    protected $dates = ['started_at', 'ended_at'];

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = ['started_at', 'ended_at'];
}

use Carbon\CarbonPeriod;

$period = CarbonPeriod::create('2019-01-01', '2019-01-31');

Event::overlaps($period);

$start = new DateTime(2019, 1, 1);
$end = new DateTime(2019, 1, 31);
$period = new DatePeriod($start, 'P1D', $end);

Event::intersects($period);

Event::whereTitle($title)->orOverlaps($period);

Event::whereTitle($title)->orIntersects($period);

Event::overlaps($period, ['created_at', 'updated_at']);