/**
  * Normalize filter input.
  *
  * @param TableBuilder $builder
  */
 public function normalize(TableBuilder $builder)
 {
     $filters = $builder->getFilters();
     $stream = $builder->getTableStream();
     foreach ($filters as $slug => &$filter) {
         /**
          * If the filter is a string then use
          * it for everything.
          */
         if (is_string($filter) && !str_contains($filter, '/')) {
             $filter = ['slug' => $filter, 'field' => $filter, 'filter' => 'field'];
         }
         /**
          * If the filter is a class string then use
          * it for the filter.
          */
         if (is_string($filter) && str_contains($filter, '/')) {
             $filter = ['slug' => $slug, 'filter' => $filter];
         }
         /**
          * Move the slug into the filter.
          */
         if (!isset($filter['slug'])) {
             $filter['slug'] = $slug;
         }
         /**
          * Move the slug to the filter.
          */
         if (!isset($filter['filter'])) {
             $filter['filter'] = $filter['slug'];
         }
         /**
          * Fallback the field.
          */
         if (!isset($filter['field']) && $stream && $stream->hasAssignment($filter['slug'])) {
             $filter['field'] = $filter['slug'];
         }
         /**
          * If there is no filter type
          * then assume it's the slug.
          */
         if (!isset($filter['filter'])) {
             $filter['filter'] = $filter['slug'];
         }
         /**
          * Set the table's stream.
          */
         if ($stream) {
             $filter['stream'] = $stream;
         }
     }
     $builder->setFilters($filters);
 }
 /**
  * Guess some table table filter placeholders.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $filters = $builder->getFilters();
     $stream = $builder->getTableStream();
     foreach ($filters as &$filter) {
         // Skip if we already have a placeholder.
         if (isset($filter['placeholder'])) {
             continue;
         }
         // Get the placeholder off the assignment.
         if ($stream && ($assignment = $stream->getAssignment(array_get($filter, 'field')))) {
             /*
              * Always use the field name
              * as the placeholder. Placeholders
              * that are assigned otherwise usually
              * feel out of context:
              *
              * "Choose an option..." in the filter
              * would just be weird.
              */
             $placeholder = $assignment->getFieldName();
             if ($this->translator->has($placeholder)) {
                 $filter['placeholder'] = $placeholder;
             }
         }
         if (!($module = $this->modules->active())) {
             continue;
         }
         $placeholder = $module->getNamespace('field.' . $filter['slug'] . '.placeholder');
         if (!isset($filter['placeholder']) && $this->translator->has($placeholder)) {
             $filter['placeholder'] = $placeholder;
         }
         $placeholder = $module->getNamespace('field.' . $filter['slug'] . '.name');
         if (!isset($filter['placeholder']) && $this->translator->has($placeholder)) {
             $filter['placeholder'] = $placeholder;
         }
         if (!array_get($filter, 'placeholder')) {
             $filter['placeholder'] = $filter['slug'];
         }
         if (!$this->translator->has($filter['placeholder']) && $this->config->get('streams::system.lazy_translations')) {
             $filter['placeholder'] = ucwords($this->string->humanize($filter['placeholder']));
         }
     }
     $builder->setFilters($filters);
 }
 /**
  * Resolve table views.
  *
  * @param TableBuilder $builder
  */
 public function resolve(TableBuilder $builder)
 {
     $this->resolver->resolve($builder->getFilters(), compact('builder'));
 }