/**
  * Handle the command.
  *
  * @param FieldFormBuilder $builder
  */
 public function handle(FieldFormBuilder $builder)
 {
     $id = $builder->getEntry();
     $namespace = $builder->getFieldNamespace();
     $builder->setFields(['name' => ['label' => 'streams::field.name.name', 'instructions' => 'streams::field.name.instructions', 'type' => 'anomaly.field_type.text', 'required' => true, 'translatable' => true, 'config' => ['max' => 64, 'suggested' => 20]], 'slug' => ['label' => 'streams::field.slug.name', 'instructions' => 'streams::field.slug.instructions', 'type' => 'anomaly.field_type.slug', 'required' => true, 'config' => ['slugify' => 'name', 'type' => '_', 'max' => 64], 'rules' => ['valid_slug', 'unique:streams_fields,slug,' . $id . ',id,namespace,' . $namespace], 'validators' => ['valid_slug' => ['handler' => SlugValidator::class, 'message' => 'streams::validation.invalid']]], 'placeholder' => ['label' => 'streams::field.placeholder.name', 'instructions' => 'streams::field.placeholder.instructions', 'type' => 'anomaly.field_type.text', 'translatable' => true], 'instructions' => ['label' => 'streams::field.instructions.name', 'instructions' => 'streams::field.instructions.instructions', 'type' => 'anomaly.field_type.textarea', 'translatable' => true], 'warning' => ['label' => 'streams::field.warning.name', 'instructions' => 'streams::field.warning.instructions', 'type' => 'anomaly.field_type.text', 'translatable' => true]]);
     if (($type = $builder->getFormEntry()->getType()) || ($type = $builder->getFieldType())) {
         $this->dispatch(new GetConfigFields($builder, $type));
     }
 }
 /**
  * Handle the form sections.
  *
  * @param FieldFormBuilder $builder
  */
 public function handle(FieldFormBuilder $builder, Repository $config)
 {
     $builder->setSections(['field' => ['fields' => function (FieldFormBuilder $builder) {
         return array_map(function ($field) {
             return $field['field'];
         }, array_filter($builder->getFields(), function ($field) {
             // No config fields.
             if (starts_with($field['field'], 'config.')) {
                 return false;
             }
             // Only default locale fields.
             if (isset($field['locale']) && $field['locale'] !== config('app.fallback_locale')) {
                 return false;
             }
             return true;
         }));
     }]]);
     if (($type = $builder->getFormEntry()->getType()) || ($type = $builder->getFieldType())) {
         if ($sections = $config->get($type->getNamespace('config/sections'))) {
             foreach ($sections as $slug => $section) {
                 $builder->addSection($slug, $section);
             }
         } else {
             $builder->addSection('configuration', ['fields' => function (FieldFormBuilder $builder) {
                 return array_map(function ($field) {
                     return $field['field'];
                 }, array_filter($builder->getFields(), function ($field) {
                     // Only config fields.
                     if (!starts_with($field['field'], 'config.')) {
                         return false;
                     }
                     // Only default locale fields.
                     if (isset($field['locale']) && $field['locale'] !== config('app.fallback_locale')) {
                         return false;
                     }
                     return true;
                 }));
             }]);
         }
     }
 }