2017 © Pedro Peláez
 

library laravel5-inputpipe

A simple way to format user input for laravel 5

image

cyvelnet/laravel5-inputpipe

A simple way to format user input for laravel 5

  • Sunday, December 27, 2015
  • by cyvelnet
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Laravel5-InputPipes

Build Status Latest Stable Version Latest Unstable Version License, (*1)

We all face the problems when user submit a form, and all these form data is a mess, sometime we even wanted to trim the inputs, cast them, and reformat them, in fact it is not the hardest thing in the world, but these small tasks really make our code look lengthy, and InputPipes comes into play., (*2)

$inputs = Pipe::make(Input::all(), ['email' => 'trim|lower', 'name' => 'trim|ucword'])->get();, (*3)

This single line of code simply the time we spend on formatting input., (*4)

Require this package with composer with the following command:, (*5)

composer require cyvelnet/laravel5-inputpipe, (*6)

Add the ServiceProvider to the providers array in config/app.php, (*7)

Cyvelnet\InputPipe\InputPipeServiceProvider::class, (*8)

and register Facade, (*9)

Cyvelnet\InputPipe\Facades\PipeFacade::class, (*10)

Available Pipes
  • trim
  • snake (snake case)
  • camel (camel case)
  • lower (lower case)
  • upper (upper case)
  • ucword
  • slug
  • ... and more coming soon or a PR to add general pipes
Extend functionality

Sometime we wanted to add some logic which is currently not provided or not a general scope, no worry you can extend it to match you usage, (*11)

Pipe::extend('sample', function ($data, $parameters) { return $data; });, (*12)

The above scenario is perfectly fine, if only a small number of extra functionality to add on. When extensions get crowded, it is better to organize them into class., (*13)

php class CustomPipes extends \Cyvelnet\InputPipe\Pipes { public function pipeFoo ($data, $parameters) { // process your logic; } public function pipeBar($data, $parameters) { // process another logic; } }, (*14)

Then register you class with, (*15)

Pipe::extra(function($data, $pipes) { return new CustomPipes($data, $pipes); });, (*16)

Finally trigger your pipes, (*17)

$inputs = Pipe::make(Input::only('foo', 'bar'), ['foo', 'bar'])->get();, (*18)

To Do

  • Laravel5 FormRequest like class to store the rules ?

The Versions

27/12 2015

dev-master

9999999-dev

A simple way to format user input for laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar cyvelnet

28/10 2015

dev-analysis-zOKLRz

dev-analysis-zOKLRz

A simple way to format user input for laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar cyvelnet

25/10 2015

v1.0.0

1.0.0.0

A simple way to format user input for laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar cyvelnet