Lint
This commit is contained in:
parent
9d7d039530
commit
94397165c6
|
@ -41,7 +41,7 @@ class CheckboxField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => $this->required ? ['boolean', 'accepted'] : ['present', 'boolean'],
|
||||
|
@ -51,7 +51,7 @@ class CheckboxField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => $this->name,
|
||||
|
@ -61,7 +61,7 @@ class CheckboxField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class CheckboxesField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => 'array',
|
||||
|
@ -52,7 +52,7 @@ class CheckboxesField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [
|
||||
...collect($this->options)->mapWithKeys(fn ($option, $key) => [$this->key . '.' . $key => $this->name])->toArray(),
|
||||
|
@ -63,7 +63,7 @@ class CheckboxesField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class DateField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
$rules = [$this->required ? 'required' : 'nullable'];
|
||||
|
||||
|
@ -61,7 +61,7 @@ class DateField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => $this->name,
|
||||
|
@ -71,7 +71,7 @@ class DateField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key . '.before_or_equal' => $this->name . ' muss ein Datum vor oder gleich dem ' . now()->format('d.m.Y') . ' sein.',
|
||||
|
|
|
@ -42,7 +42,7 @@ class DropdownField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => $this->required ? ['required', 'string', Rule::in($this->options)] : ['nullable', 'string', Rule::in($this->options)],
|
||||
|
@ -52,7 +52,7 @@ class DropdownField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->name];
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class DropdownField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ abstract class Field extends Data
|
|||
abstract public static function default();
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
abstract public function getRegistrationRules(): array;
|
||||
abstract public function getRegistrationRules(Form $form): array;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
abstract public function getRegistrationAttributes(): array;
|
||||
abstract public function getRegistrationAttributes(Form $form): array;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
abstract public function getRegistrationMessages(): array;
|
||||
abstract public function getRegistrationMessages(Form $form): array;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
abstract public static function fake(Generator $faker): array;
|
||||
|
|
|
@ -48,7 +48,7 @@ class GroupField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
|
||||
$rules = [$this->required ? 'required' : 'nullable'];
|
||||
|
@ -69,7 +69,7 @@ class GroupField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->name];
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class GroupField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -37,16 +37,15 @@ class NamiField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
$rules = [];
|
||||
$fields = request()->route('form')->getFields();
|
||||
|
||||
$c = collect($fields)
|
||||
$c = collect($form->getFields())
|
||||
->filter(fn ($field) => $field['for_members'] === true)
|
||||
->filter(fn ($field) => $field['nami_type'] === null)
|
||||
->filter(fn ($field) => $field['type'] !== class_basename(static::class))
|
||||
->map(fn ($field) => Field::fromConfig($field)->getRegistrationRules());
|
||||
->map(fn ($field) => Field::fromConfig($field)->getRegistrationRules($form));
|
||||
|
||||
foreach ($c as $field) {
|
||||
foreach ($field as $ruleKey => $rule) {
|
||||
|
@ -63,20 +62,20 @@ class NamiField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
$rules = [];
|
||||
$fields = request()->route('form')->getFields();
|
||||
$inputMembers = request($this->key);
|
||||
|
||||
$c = collect($fields)
|
||||
$c = collect($form->getFields())
|
||||
->filter(fn ($field) => $field['type'] !== class_basename(static::class))
|
||||
->filter(fn ($field) => $field['for_members'] === true)
|
||||
->map(fn ($field) => Field::fromConfig($field));
|
||||
|
||||
foreach ($c as $field) {
|
||||
foreach ($field->getRegistrationRules() as $ruleKey => $rule) {
|
||||
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
||||
|
||||
$message = $field->name . ' für ein Mitglied';
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
|
@ -103,7 +102,7 @@ class NamiField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class RadioField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [
|
||||
$this->key => $this->required ? ['required', 'string', Rule::in($this->options)] : ['nullable', 'string', Rule::in($this->options)],
|
||||
|
@ -53,7 +53,7 @@ class RadioField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->name];
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class RadioField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class TextField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->required ? ['required', 'string'] : ['nullable', 'string']];
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class TextField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->name];
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class TextField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class TextareaField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationRules(): array
|
||||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->required ? ['required', 'string'] : ['nullable', 'string']];
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class TextareaField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
public function getRegistrationAttributes(Form $form): array
|
||||
{
|
||||
return [$this->key => $this->name];
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class TextareaField extends Field
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
public function getRegistrationMessages(Form $form): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class Form extends Model implements HasMedia
|
|||
|
||||
return [
|
||||
...$carry,
|
||||
...$field->getRegistrationRules(),
|
||||
...$field->getRegistrationRules($this),
|
||||
];
|
||||
}, []);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Form extends Model implements HasMedia
|
|||
|
||||
return [
|
||||
...$carry,
|
||||
...$field->getRegistrationMessages(),
|
||||
...$field->getRegistrationMessages($this),
|
||||
];
|
||||
}, []);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class Form extends Model implements HasMedia
|
|||
|
||||
return [
|
||||
...$carry,
|
||||
...$field->getRegistrationAttributes(),
|
||||
...$field->getRegistrationAttributes($this),
|
||||
];
|
||||
}, []);
|
||||
}
|
||||
|
|
10
phpstan.neon
10
phpstan.neon
|
@ -547,3 +547,13 @@ parameters:
|
|||
message: "#^Unable to resolve the template type TValue in call to function collect$#"
|
||||
count: 1
|
||||
path: app/Form/Models/Form.php
|
||||
|
||||
-
|
||||
message: "#^Unable to resolve the template type TKey in call to function collect$#"
|
||||
count: 1
|
||||
path: app/Form/Fields/NamiField.php
|
||||
|
||||
-
|
||||
message: "#^Unable to resolve the template type TValue in call to function collect$#"
|
||||
count: 1
|
||||
path: app/Form/Fields/NamiField.php
|
||||
|
|
|
@ -18,6 +18,7 @@ use Worksome\RequestFactories\RequestFactory;
|
|||
* @method self parentGroup(int $groupId)
|
||||
* @method self parentField(string $fieldKey)
|
||||
* @method self namiType(?NamiType $type)
|
||||
* @method self forMembers(bool $forMembers)
|
||||
*/
|
||||
class FormtemplateFieldRequest extends RequestFactory
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue