PHP code example of brunaobh / eloquent-ql

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

    

brunaobh / eloquent-ql example snippets




namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Search;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $res = Search::handleRequest($request)
            ->negotiate('User')
            ->get();
        
        return response()->json($res);
    }

public function scopeFilterByAddressNotNull($query)
{
   return $query->whereNotNull('address');
}