承接 cyvelnet/laravel5-inputpipe 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cyvelnet/laravel5-inputpipe

最新稳定版本:v1.0.0

Composer 安装命令:

composer require cyvelnet/laravel5-inputpipe

包简介

A simple way to format user input for laravel 5

README 文档

README

Build Status Latest Stable Version Latest Unstable Version License

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.

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

This single line of code simply the time we spend on formatting input.

Require this package with composer with the following command:

composer require cyvelnet/laravel5-inputpipe

Add the ServiceProvider to the providers array in config/app.php

Cyvelnet\InputPipe\InputPipeServiceProvider::class

and register Facade

Cyvelnet\InputPipe\Facades\PipeFacade::class

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

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

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.

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

Then register you class with

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

Finally trigger your pipes

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

To Do

  • Laravel5 FormRequest like class to store the rules ?

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固