2023-07-07 00:05:38 +06:00
|
|
|
<?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;
|
|
|
|
}
|
|
|
|
|
2023-07-09 19:39:37 +06:00
|
|
|
private function getTitle(): string
|
2023-07-07 00:05:38 +06:00
|
|
|
{
|
|
|
|
return Str::ucfirst($this->title);
|
|
|
|
}
|
|
|
|
|
2023-07-09 19:39:37 +06:00
|
|
|
private function getType(): string
|
2023-07-07 00:05:38 +06:00
|
|
|
{
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
2023-07-09 19:39:37 +06:00
|
|
|
private function getValue(): string
|
2023-07-07 00:05:38 +06:00
|
|
|
{
|
|
|
|
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()
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|