service-captcha/app/View/Components/Private/Forms/Form.php

33 lines
740 B
PHP

<?php declare(strict_types=1);
namespace App\View\Components\Private\Forms;
use Illuminate\Support\Str;
use Illuminate\View\Component;
use Illuminate\View\View;
abstract class Form extends Component
{
private ?string $requestName = null;
abstract protected function getName(): string;
abstract public function render(): View;
protected function getRequestName(): string
{
if (!is_null($this->requestName)) {
return $this->requestName;
}
$this->requestName = Str::of($this->getName())
->replace(
['.', '[', ']'],
['_', '.', ''],
)
->rtrim('.')
->value();
return $this->requestName;
}
}