PHP code example of apichef / laravel-request-query-helper

1. Go to this page and download the library: Download apichef/laravel-request-query-helper 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/ */

    

apichef / laravel-request-query-helper example snippets


return [
    /* Configuration for inclusion of related resources */
    'resource collections */
    'filter' => [
        'name' => 'filter',
    ],

    /* Configuration for sorting resource collections */
    'sort' => [
        'name' => 'sort',
    ],

    /* Configuration for sparse field-sets */
    'fields' => [
        'name' => 'fields',
    ],

    /* Configuration for pagination */
    'pagination' => [
        'name' => 'page',
        'number' => 'number',
        'size' => 'size',
    ],
];

use Illuminate\Http\Request;

class ExampleController extends Controller
{
    public function show(Request $request)
    {
        $params = $request->ts.sort'); // true
        $params->has('comments.foo'); // false
        $params->has('author'); // true
        
        // get
        
        $params->get('comments.limit'); // [5]
        $params->get('comments.sort'); // ['created_at', 'desc']
        
        // isEmpty
        
        $params->isEmpty('comments'); // false
        $params->isEmpty('author'); // true
    }
}

## Sorts

// todo

## Fields

// todo

## Pagination

// todo
bash
$ php artisan vendor:publish --provider="ApiChef\RequestQueryHelper\RequestQueryHelperServiceProvider"

GET '/posts?