51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
|
<?php declare(strict_types=1);
|
||
|
|
||
|
namespace App\View\Components\Private\Forms;
|
||
|
|
||
|
use Illuminate\Support\Str;
|
||
|
use Illuminate\View\View;
|
||
|
|
||
|
final class Input extends Form
|
||
|
{
|
||
|
public function __construct(
|
||
|
private readonly string $title,
|
||
|
private readonly string $name,
|
||
|
private readonly string $type = 'text',
|
||
|
private readonly ?string $value = ''
|
||
|
) { }
|
||
|
|
||
|
protected function getName(): string
|
||
|
{
|
||
|
return $this->name;
|
||
|
}
|
||
|
|
||
|
protected function getTitle(): string
|
||
|
{
|
||
|
return Str::ucfirst($this->title);
|
||
|
}
|
||
|
|
||
|
protected function getType(): string
|
||
|
{
|
||
|
return $this->type;
|
||
|
}
|
||
|
|
||
|
protected function getValue(): string
|
||
|
{
|
||
|
return (string) old($this->getRequestName(), $this->value);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritDoc
|
||
|
*/
|
||
|
public function render(): View
|
||
|
{
|
||
|
return view('private.components.forms.input', [
|
||
|
'title' => $this->getTitle(),
|
||
|
'name' => $this->getName(),
|
||
|
'requestName' => $this->getRequestName(),
|
||
|
'type' => $this->getType(),
|
||
|
'value' => $this->getValue()
|
||
|
]);
|
||
|
}
|
||
|
}
|