23 lines
464 B
PHP
23 lines
464 B
PHP
<?php
|
|
|
|
namespace App\Shared\Http;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class RequestInput
|
|
{
|
|
public function __construct(private Request $request) {}
|
|
|
|
public function string(string $key): ?string
|
|
{
|
|
$value = $this->request->input($key);
|
|
if (is_string($value)) {
|
|
return $value;
|
|
}
|
|
if (is_int($value) || is_float($value) || is_bool($value)) {
|
|
return (string) $value;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|