PHP code example of mjarestad / filtry

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

    

mjarestad / filtry example snippets




use Mjarestad\Filtry\Http\Requests\Request;

class StorePostRequest extends Request
{
    public function rules()
    {
        return [
            'author' => '=> 'trim|replace:%,percent|slug',
        ];
    }
}



class Post extends Eloquent {

    public static $filters = array(
        'author' => 'trim|ucwords',
        'slug'   => 'trim|replace:%,percent|slug'
    );

    public static $rules = array(
        'author' => '



$filtry = Filtry::make(Input::all(), Post::$filters);



$validator = Validator::make($filtry->getFiltered(), Post::$rules);



$filtry->getOld();



Filtry::trim('some string');
Filtry::slug('some string');
Filtry::snakeCase('some string');



$filters = [
    'author' => 'trim|ucwords',
    'slug'   => 'trim|replace:%,percent|slug',
];

$data = [
    'author' => 'John Doe',
    'slug'   => 'My post title',
];

$filtry = new Mjarestad\Filtry\Filtry;
$filtry->make($data, $filters);
$filteredData = $filtry->getFiltered();



Filtry::extend('my_custom_filter', function ($data) {
    return str_replace('-', '_', $data);
});



Filtry::myCustomFilter('some-custom-string');



Filtry::extend('custom_filter', function ($data, $param1, $param2) {
    return $data . ($param1 + $param2);
});



use Mjarestad\Filtry\Http\Requests\Request;

class StorePostRequest extends Request
{
    public function rules()
    {
        return [
            'author' => '



$filtry = new Mjarestad\Filtry\Filtry;

$filtry->extend('my_custom_filter', function ($data) {
    return str_replace('-', '_', $data);
});

$filtry->myCustomFilter('some-custom-string');

'Filtry'  => 'Mjarestad\Filtry\Facades\Filtry',