Skip to content

Instantly share code, notes, and snippets.

@sirawitpra
Created April 24, 2017 07:59
Show Gist options
  • Save sirawitpra/6ada467078bc159ace2e137cd6dd788c to your computer and use it in GitHub Desktop.
Save sirawitpra/6ada467078bc159ace2e137cd6dd788c to your computer and use it in GitHub Desktop.
<?php
namespace Illuminate\Foundation\Http\Middleware;
class TrimStrings extends TransformsRequest
{
/**
* The attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
//
];
/**
* Transform the given value.
*
* @param string $key
* @param mixed $value
* @return mixed
*/
protected function transform($key, $value)
{
if (in_array($key, $this->except, true)) {
return $value;
}
return is_string($value) ? trim($value) : $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment