1. Go to this page and download the library: Download axn/laravel-request-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/ */
axn / laravel-request-filters example snippets
namespace App\Http\Requests;
use Axn\RequestFilters\FilterableFormRequest;
use Illuminate\Foundation\Http\FormRequest;
class MyRequest extends FormRequest
{
use FilterableFormRequest;
public function filters()
{
return [
'name' => 'stripped|trim'
];
}
//...
}
//...
public function filters()
{
return [
'name' => [
'stripped',
'trim'
]
];
}
//...
//...
public function filters()
{
return [
'name' => 'stripped|trim|strtolower|ucwords'
];
}
//...
//...
public function filters()
{
return [
'name' => [
'stripped',
'trim',
'Foo::Bar'
]
];
}
//...
class Foo
{
public static function Bar($str)
{
return ucwords(strtolower($str));
}
}
//...