Create filters which transform input values, by removing or changing characters within the value.
abstractrs/laravel-filters is a Laravel package for create filters which transform input values, by removing or changing characters within the value..
It currently has 0 GitHub stars and 678 downloads on Packagist (latest version v2.09).
Install it with composer require abstractrs/laravel-filters.
Discover more Laravel packages by abstractrs
or browse all Laravel packages to compare alternatives.
Last updated
This package allows you to easily create / use filters which transform input values, by removing or changing characters within the value.
composer require abstractrs/laravel-filters
Laravel will discover the package by itself. If you feel old-school, disable auto-discovery and add Abstractrs\Form\Request\RequestFilterProvider::class to the providers array in your config/app.php.
php artisan vendor:publish --tag=laravel-filters
config/filters.php<?php
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'
];
php artisan make:filter RemoveCharsFilter
<?php
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)
];
}
//...
}