auto cleanup input using https://github.com/GrahamCampbell/Laravel-Binput via middleware ex.
protected $middleware = [
// ...
\App\Http\Middleware\External\CleanEvilInput::class,
];
auto cleanup input using https://github.com/GrahamCampbell/Laravel-Binput via middleware ex.
protected $middleware = [
// ...
\App\Http\Middleware\External\CleanEvilInput::class,
];
<?php | |
namespace App\Http\Middleware\External; | |
use GrahamCampbell\Binput\Facades\Binput; | |
use Illuminate\Foundation\Http\Middleware\TransformsRequest; | |
class CleanEvilInput extends TransformsRequest | |
{ | |
/** | |
* The attributes that should not be edited. | |
* | |
* @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 Binput::clean($value, true, true); | |
} | |
} |