FleetCart/app/Http/Middleware/ConvertStringBooleans.php

29 lines
613 B
PHP
Raw Permalink Normal View History

2023-06-11 12:14:03 +00:00
<?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;
}
}