29 lines
613 B
PHP
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;
|
||
|
}
|
||
|
}
|