PHP code example of abstractrs / laravel-filters

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

    

abstractrs / laravel-filters example snippets




return [
    'aliases' => [
        'encrypt' => \Abstractrs\Form\Request\Filters\EncryptFilter::class,
        'decrypt' => \Abstractrs\Form\Request\Filters\DecryptFilter::class,
        'hash'    => \Abstractrs\Form\Request\Filters\HashFilter::class,
        'lower'   => \Abstractrs\Form\Request\Filters\StringToLowerFilter::class,
        'upper'   => \Abstractrs\Form\Request\Filters\StringToUpperFilter::class,
        'null'    => \Abstractrs\Form\Request\Filters\ToNullFilter::class,
        'int'     => \Abstractrs\Form\Request\Filters\ToIntFilter::class,
    ],
    'namespace' => 'Http\\Filters'
];




namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LoginRequest extends FormRequest {
    
    //Filter
    public function filters()
    {
        return [
            'name'  => 'lower|hash',
            'names' => 'array:lower', // Call lower filter for each array value
            'id'    => 'int',
            'date'  => 'carbon,d/m/Y',
            'created_date'  => 'carbon' //default format -> filters.date_format (Y-m-d H:i:s)
        ];
    }
    
    //...
    
}

php artisan vendor:publish --tag=laravel-filters