/**
  * Handle the command.
  *
  * @param AssignmentRepositoryInterface $assignments
  */
 public function handle(AssignmentRepositoryInterface $assignments)
 {
     if ($this->builder->getFormOption('auto_assign') === true && $this->builder->getFormMode() === 'create') {
         $field = $this->builder->getFormEntry();
         $stream = $this->builder->getStream();
         $assignments->create(['stream_id' => $stream->getId(), 'field_id' => $field->getId()]);
     }
 }
 /**
  * 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;
                 }));
             }]);
         }
     }
 }
 /**
  * Create a new VariableFieldFormBuilder instance.
  *
  * @param Form          $form
  * @param VariableModel $model
  */
 public function __construct(Form $form, VariableModel $model)
 {
     $this->setStream($model->getStream());
     parent::__construct($form);
 }
 /**
  * Return the form for an existing field.
  *
  * @param FieldFormBuilder $form
  * @param                  $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function edit(FieldFormBuilder $form, $id)
 {
     return $form->render($id);
 }
 /**
  * Return a form to edit the field.
  *
  * @param AssignmentRepositoryInterface $assignments
  * @param FieldFormBuilder              $form
  * @param UserModel                     $model
  * @param                               $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function edit(AssignmentRepositoryInterface $assignments, FieldFormBuilder $form, UserModel $model, $id)
 {
     /* @var AssignmentInterface $assignment */
     $assignment = $assignments->find($id);
     return $form->setStream($model->getStream())->render($assignment->getFieldId());
 }