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.
|
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @param $key
|
|
|
|
* @param $value
|
|
|
|
*
|
2023-06-11 12:14:03 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
protected function transform($key, $value): mixed
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
if ($value === 'true' || $value === 'TRUE') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($value === 'false' || $value === 'FALSE') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
}
|