PHP code example of vati / filtero

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

    

vati / filtero example snippets


    use Vati\Filtero\FilterTrait;

    class YourModel extends Model
    {
        use FilterTrait;

        /**
         * The columns that are searchable.
         *
         * @var array
         */
        protected array $searchable = [
            'status',
            [
                'recipient' => [
                    'CONCAT_WS(" ", first_name, last_name)'
                ], 
                'currency' => [
                    'code'
                ]
            ],
        ];

        /**
         * The columns that are filterable.
         *
         * @var array
         */
        protected array $filterable = [
            'status',
            'currency_id',
            'provider_transaction_id',
            [
                'recipient' => [
                    'country_id', 
                    'city', 
                    'phone', 
                    'email'
                ]
            ],
        ];
   
       /**
        * The columns that are sortable.
        *
        * @var array
        */
        protected array $sortable = [
            'id',
            'user_id',
            'recipient_id',
            'recipient.first_name', //relation sort
            'payout_id',
            'estimated_provider_fee{sum}estimated_platform_fee', // sum multiple columns, order must be same in http_query
            'payment_amount',
            'total_amount',
            'currency_id',
            'status',
            'reference',
            'created_at'
        ];
    }
    

    $payments = YourModel::with(['recipient'])->search()->filter()->sort()->paginate($request->per_page ?? 10);
    

$payments = YourModel::with(['recipient'])
            ->search()
            ->filter()
            ->sort()
            ->paginate($request->per_page ?? 10);

// Example request URL
?range[price][min]=10&range[price][max]=100
bash
php artisan vendor:publish --provider="Vati\Filtero\FilteroServiceProvider"