FleetCart/app/Http/Middleware/ConvertStringBooleans.php
2023-06-11 13:14:03 +01:00

29 lines
613 B
PHP

<?php
namespace FleetCart\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
class ConvertStringBooleans extends TransformsRequest
{
/**
* Transform the given value.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
protected function transform($key, $value)
{
if ($value === 'true' || $value === 'TRUE') {
return true;
}
if ($value === 'false' || $value === 'FALSE') {
return false;
}
return $value;
}
}