PHP code example of primitive / flexible-where-between

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

    

primitive / flexible-where-between example snippets

 php
$logs = Log::query();

if ((empty($end_date) && (empty($start_date))
{
    $logs = $logs->get();
}

else if (empty($end_date)) 
{
   $logs = $logs->where('created_at','>=', $start_date);
}
else if (empty($start_date)) 
{
   $logs = $logs->where('created_at','<=', $end_date);
} 
else 
{
   $logs = $logs->whereBetween('created_at', [$start_date, $end_date])
}

 php
Log::whereBetween('created_at', [$start_date, $end_date])