@param ClassMetadataBuilder $builder

@throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
@throws \ReflectionException
@SuppressWarnings(PHPMD.StaticAccess)
972692
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $builder->addManyToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class
        );
    }
1184390
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $manyToOne = $builder->createManyToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class
        );
        $manyToOne
            ->inversedBy(self::getDoctrineStaticMeta()->getPlural())
            ->addJoinColumn(
                Inflector::tableize(
                    TemplateEntity::getDoctrineStaticMeta()->getSingular()
                ) . '_' . IdFieldInterface::PROP_ID,
                IdFieldInterface::PROP_ID,
                true
            )->build();

    }
1094441
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        foreach (array_filter($this->filters()) as $name => $value) {
            if (method_exists($this, $name)) {
                call_user_func_array([$this, $name], [$value]);
            }
        }

        return $this->builder;
    }
1097292
public function prepare($builder = null)
    {
        // NOTE: because the same ActiveQuery may be used to build different SQL statements
        // (e.g. by ActiveDataProvider, one for count query, the other for row data query,
        // it is important to make sure the same ActiveQuery can be used to build SQL statements
        // multiple times.
        if (!empty($this->joinWith)) {
            $this->buildJoinWith();
            $this->joinWith = null;
        }

        return $this;
    }
353933
protected function instantiationOptions(SchemaBuilder $builder)
    {
        if ($this->getInstantiator() != DocumentInstantiator::class) {
            //Unable to define options for non default inheritance based instantiator
            return null;
        }

        //Let's define a way how to separate one model from another based on given fields
        $helper = new InheritanceHelper($this, $builder->getSchemas());

        return $helper->makeDefinition();
    }
93446
public function get(Builder $builder)
    {
        // First, we will retrieve the field's value using our composed behavior.
        $value = $this->behavior->get(
            $builder->field,
            $builder->id,
            ! $builder->raw
        );

        // Next, we will iterate over the defined components and pass our value
        // through each component's method if it was defined on the builder.
        foreach ($this->components as $component) {
            if (! is_null($builder->$component)) {
                $method = 'run'.ucfirst($component);

                $value = $this->$method($builder->$component, $value);
            }
        }

        return $value;
    }
291033
public function extend(Builder $builder): void
    {
        foreach ($this->extensions as $extension) {
            $this->{"add{$extension}"}($builder);
        }
    }
19243
public function setBuilder(IlluminateEloquentBuilder $builder = null)
    {
        // If no builder was provided,
        // we'll use the one from this repositorys model
        if (empty($builder)) {
            $builder = $this->getModel()->newQuery();
        }

        // Set repository builder
        $this->builder = $builder;

        return $this;
    }
543229
protected function addWithNotKept(Builder $builder): void
    {
        $builder->macro('withNotKept', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
427479
private function remapBuilderColumns(Builder $builder): void {
    if($builder->aggregate === null) {
      if($builder->columns === ['*']) {
        $builder->columns = array_keys($this->to_db);
      }

      if(is_string($builder->columns)) {
        $builder->columns = [$builder->columns];
      }

      $this->remapColumns($builder->columns);
    } else {
      if($builder->aggregate['columns'] == ['*']) {
        return;
      }

      $this->remapColumns($builder->aggregate['columns'], false);
    }
  }
808218
public function extend(Builder $builder)
    {
        foreach ($this->extensions as $extension) {
            $this->{"add{$extension}"}($builder);
        }

        $builder->onDelete(function(Builder $builder)
        {
            $column = $this->getDeletedAtColumn($builder);

            return $builder->update(array(
                $column => $builder->getModel()->freshTimestampString()
            ));
        });
    }
427461
public static function make(ClassMetadataBuilder $builder, $type, $name)
    {
        $type = Type::getType($type);

        $field = $builder->createField($name, $type->getName());

        return new static($field, $builder, $type, $name);
    }
869827
public function remove(Builder $builder)
    {
        $column = $builder->getModel()->getQualifiedDeletedAtColumn();

        $query = $builder->getQuery();

        foreach ((array) $query->wheres as $key => $where) {
            if ($this->isSoftDeleteConstraint($where, $column)) {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
272648
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        // We need to select all columns from the original
        // table, since many joins can mess up the selected fields
        $this->builder->select("{$this->getTableName()}.*");

        foreach ($this->filters() as $name => $value) {
            $this->callFilterMethod($name, $value);
        }

        return $this->builder;
    }
1326988
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $unidirectionalOneToOn = $builder->createOneToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class
        );
        $unidirectionalOneToOn->addJoinColumn(
            Inflector::tableize(
                TemplateEntity::getDoctrineStaticMeta()->getSingular()
            ) . '_' . IdFieldInterface::PROP_ID,
            IdFieldInterface::PROP_ID,
            true
        )->build();
    }
591229
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
    {
        return $this->builder->createOneToOne(
            $relation,
            $entity
        );
    }
152411
protected function addRestore(Builder $builder)
    {
        $builder->macro('restore', function(Builder $builder)
        {
            $builder->withTrashed();

            return $builder->update(array($builder->getModel()->getDeletedAtColumn() => null));
        });
    }