PHP code example of red-fern / laravel-array-query-builder

1. Go to this page and download the library: Download red-fern/laravel-array-query-builder 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/ */

    

red-fern / laravel-array-query-builder example snippets


$users = User::where('name', 'like', '%john%')
        ->whereHas('orders', function($q) {
            $q->where('order_date', '>', '2019-01-01 00:00:00');
        })->get();

$users = User::where(function($q) {
                $q->where('name', '=', 'john')
                    ->orWhere('name', '=', 'james');
            })
            ->whereHas('orders', function($q) {
                $q->where('order_date', '>', '2010-01-01 00:00:00');
            })->get();