/**
  * Handle the command.
  *
  * @param RelationshipFieldType $fieldType
  * @param AddonCollection       $addons
  * @param Repository            $config
  * @return array
  */
 public function handle(RelationshipFieldType $fieldType, AddonCollection $addons, Repository $config)
 {
     $definition = [];
     /* @var Addon $addon */
     foreach ($addons->withConfig('lookup.' . $this->table->config('related')) as $addon) {
         $definition = $config->get($addon->getNamespace('lookup.' . $this->table->config('related')));
     }
     $definition = $config->get($fieldType->getNamespace('lookup.' . $this->table->config('related')), $definition);
     return $definition;
 }
 /**
  * Handle the options.
  *
  * @param RelationshipFieldType $fieldType
  * @return array
  */
 public function handle(RelationshipFieldType $fieldType)
 {
     $model = $fieldType->getRelatedModel();
     if (!$model instanceof EloquentModel) {
         return [];
     }
     $query = $model->newQuery();
     $title = array_get($fieldType->getConfig(), 'title');
     $key = array_get($fieldType->getConfig(), 'key');
     return array_filter([null => $fieldType->getPlaceholder()] + $query->get()->lists($title ?: $model->getTitleName(), $key ?: $model->getKeyName()));
 }
 /**
  * Handle the command.
  *
  * @param Container $container
  */
 public function handle(Container $container)
 {
     $handler = array_get($this->fieldType->getConfig(), 'handler');
     if (!class_exists($handler) && !str_contains($handler, '@')) {
         $handler = array_get($this->fieldType->getHandlers(), $handler);
     }
     if (is_string($handler) && !str_contains($handler, '@')) {
         $handler .= '@handle';
     }
     $container->call($handler, ['fieldType' => $this->fieldType]);
 }
Exemplo n.º 4
0
 /**
  * Handle the options.
  *
  * @param RelationshipFieldType     $fieldType
  * @param FieldRepositoryInterface  $fields
  * @param StreamRepositoryInterface $streams
  * @return array
  */
 public function handle(RelationshipFieldType $fieldType, FieldRepositoryInterface $fields, StreamRepositoryInterface $streams)
 {
     $stream = array_get($fieldType->getConfig(), 'stream');
     $unlocked = array_get($fieldType->getConfig(), 'unlocked');
     $namespace = array_get($fieldType->getConfig(), 'namespace');
     $fields = $fields->findAllByNamespace($namespace);
     if ($stream && ($stream = $streams->findBySlugAndNamespace($stream, $namespace))) {
         $fields = $fields->assignedTo($stream);
     }
     if ($unlocked) {
         $fields = $fields->unlocked();
     }
     $fieldType->setOptions(array_combine($fields->lists('id')->toArray(), $fields->lists('name')->toArray()));
 }
 /**
  * Handle the options.
  *
  * @param RelationshipFieldType $fieldType
  * @return array
  */
 public function handle(RelationshipFieldType $fieldType)
 {
     $model = $fieldType->getRelatedModel();
     $query = $model->newQuery();
     $fieldType->setOptions($query->get()->lists($model->getTitleName(), $model->getKeyName())->all());
 }