Create an instance of the given model.

@param  array $customAttributes Custom attributes that will override the guessed formatters.
@param  bool  $persist
@return Model|Collection
961779
public function make($customAttributes = [], $persist = false)
    {
        if (is_string($customAttributes)) {
            return $this->populator->make(...func_get_args());
        }

        // This condition prevents the overwriting of the custom attributes
        // thay may have been passed to add().
        if ($customAttributes) {
            $this->customAttributes = $customAttributes;
        }

        return last($this->populator->execute($persist));
    }
601166
public static function createForModel($model, $attributes)
    {
        $model = static::makeForModel($model, $attributes);

        $model->save();

        return $model;
    }
559696
public function execute($persistLastModel = true)
    {
        $this->addLastModel();

        $insertedPKs = [];
        $createdModels = [];

        foreach ($this->quantities as $modelClass => $quantity) {
            $this->modelPopulators[$modelClass]->setGuessedColumnFormatters(false);

            $persist = $modelClass === $this->lastModelClass ? $persistLastModel : true;

            if ($quantity > 1) {
                $createdModels[$modelClass] = (new $modelClass)->newCollection();
            }

            for ($i = 0; $i < $quantity; $i++) {
                $createdModel = $this->modelPopulators[$modelClass]->run($insertedPKs, $persist);

                $insertedPKs[$modelClass][] = $createdModel->getKey();

                if ($quantity === 1) {
                    $createdModels[$modelClass] = $createdModel;
                } else {
                    $createdModels[$modelClass]->add($createdModel);
                }
            }
        }

        // We'll unset the previously added models so that if, for example, the developer calls
        // $populator->create(App\Foo::class), and then $populator->create(App\Bar::class),
        // Foo won't be created twice.
        $this->forgetAddedModels();

        $this->closeDoctrineConnections();

        return $createdModels;
    }
1312971
public function create($mixed = null, $options = array())
    {
        $this->request = Strata::router()->getCurrentController()->request;

        if (!is_null($mixed) && !in_array('Strata\\Model\\CustomPostType\\ModelEntity', class_parents($mixed))) {
            throw new Exception("A form can only be linked to either an object inheriting ModelEntity or nothing at all.");
        }

        if (is_object($mixed)) {
            $this->associatedEntity = $mixed;
        }

        $this->configuration = $this->parseFormConfiguration($options);

        $formAttributes = $this->configuration;
        unset($formAttributes['hasSteps']);
        unset($formAttributes['type']);
        unset($formAttributes['nonce']);

        if (!is_null($this->associatedEntity) && $this->associatedEntity->hasValidationErrors()) {
            if (array_key_exists('class', $formAttributes)) {
                $formAttributes['class'] .= " has-errors ";
            } else {
                $formAttributes['class'] = "has-errors";
            }
        }

        $htmlAttributes = $this->arrayToHtmlAttributes($formAttributes);

        $salt = $this->getNonceSalt();
        $nonceTag = $this->generateNonceTag($salt);
        $nonceHidden = $this->generateHidden(array("name" => "auth_id"), wp_create_nonce($salt));

        return sprintf("<form %s>\n%s\n%s\n", $htmlAttributes, $nonceHidden, $nonceTag);
    }
537583
public function bindAttributes(string $modelClass, iterable $attributes): iterable
    {
        $dbPlatform = $this->getConnection()->getDatabasePlatform();
        $types      = $this->getModelSchemas()->getAttributeTypes($modelClass);

        foreach ($attributes as $column => $value) {
            assert(is_string($column) && $this->getModelSchemas()->hasAttributeType($this->getModelClass(), $column));

            $quotedColumn  = $this->quoteSingleIdentifier($column);
            $type          = $this->getDbalType($types[$column]);
            $pdoValue      = $type->convertToDatabaseValue($value, $dbPlatform);
            $parameterName = $this->createNamedParameter($pdoValue, $type->getBindingType());

            yield $quotedColumn => $parameterName;
        }
    }
396306
protected function instantiateObject(
        array &$data,
        $class,
        array &$context,
        \ReflectionClass $reflectionClass,
        $allowedAttributes,
        string $format = null
    ): object {
        return $reflectionClass->newInstanceWithoutConstructor();
    }
898136
public function render($customAttributes = null)
    {
        $output = '';

        foreach ($this->entries as $entry) {
            $isActive = false;
            $entryAttributes = [];

            if ($entry instanceof DropdownDivider) {
                $entryAttributes['role'] = 'seperator';
                $entryAttributes['class'] = 'divider';
            } else {
                if ($entry instanceof DropdownHeader) {
                    $entryAttributes['class'] = 'dropdown-header';
                } else if ($entry instanceof Content) {
                    $entryAttributes['class'] = 'content';
                } else if ($entry instanceof Link) {

                } else {
                    if (MenuHelper::isCurrentRouteWithParameters($entry->getName(), $entry->getParameters())) {
                        $entryAttributes['class'] = 'active';
                        $isActive = true;
                    } else {
                        foreach ($entry->getAdditionalRouteNames() as $additionalRouteName) {
                            if (MenuHelper::isCurrentRoute($additionalRouteName)) {
                                $entryAttributes['class'] = ' active';
                                $isActive = true;
                            }
                        }
                    }
                }
            }

            if (MenuHelper::getConfig()->getCustomDropdownItemRenderFunction() != null) {
                $output .= MenuHelper::getConfig()->getCustomDropdownItemRenderFunction()($entry, $isActive);
            } else {
                $output .= '<li ' . Html::attributes($entryAttributes) . '>' . $entry->render() . '</li>';
            }
        }

        $classes = 'dropdown-toggle';

        if (count(MenuHelper::getConfig()->getAnchorElementClasses()) > 0) {
            foreach (MenuHelper::getConfig()->getAnchorElementClasses() as $anchorElementClass) {
                $classes .= ' ' . $anchorElementClass;
            }
        }

        if (empty($this->name)) {
            $link = Html::link('#', $this->title . '<span class="caret"></span>',
                ['class' => $classes, 'data-toggle' => 'dropdown']);
        } else {
            $link = Html::linkRoute($this->name, $this->title . '<span class="caret"></span>', $this->parameters,
                ['class' => $classes, 'data-toggle' => 'dropdown']);
        }

        if (MenuHelper::getConfig()->getCustomDropdownContainerRenderFunction() != null) {
            $additionalClasses = array_key_exists('class', $this->attributes) ? $this->attributes['class'] : null;

            return MenuHelper::getConfig()->getCustomDropdownContainerRenderFunction()($link, $output, $additionalClasses);
        }

        $dropdownClasses = 'dropdown-menu';

        if (array_key_exists('class', $this->attributes)) {
            $dropdownClasses = $this->attributes['class'];
        }

        return $link . '<ul class="' . $dropdownClasses . '">' . $output . '</ul>';
    }
1186241
public function create(CustomCollection &$customCollection)
    {
        $data = $customCollection->exportData();
        $endpoint = '/admin/custom_collections.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'custom_collection' => $data
            )
        );
        $customCollection->setData($response['custom_collection']);
    }
1033091
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
    {
        if (\func_num_args() >= 3) {
            $format = \func_get_arg(2);
        } else {
            // will be deprecated in version 4
            $format = null;
        }

        $context = parent::createChildContext($parentContext, $attribute, $format);
        // format is already included in the cache_key of the parent.
        $context['cache_key'] = $this->getCacheKey($format, $context);

        return $context;
    }
921628
public function create($name, array $attr = [])
    {
        $model = $this->make($name, $attr, true);

        $this->store->persist($model);

        if ($this->triggerCallback($model, $name)) {
            $this->store->persist($model);
        }

        return $model;
    }
945868
public static function factory($attributes)
    {
        $instance = new self();
        $instance->revokedPaymentMethod = PaymentMethodParser::parsePaymentMethod($attributes);
        $instance->customerId = $instance->revokedPaymentMethod->customerId;
        $instance->token = $instance->revokedPaymentMethod->token;
        return $instance;
    }
1060008
public static function create($attributes = [])
    {
        try {
            self::init();
            foreach ($attributes as $column => $value) {
                $columns[] = $column;
                $values[] = ':'.$column;
            }

            $sql = 'INSERT INTO ' . self::$modelTable . ' (' . implode(',', $columns) . ') VALUES (' . implode(',', $values) . ')';
            $stm = self::$connect->prepare($sql);
            $stm->execute($attributes);
            return self::find(self::$connect->lastInsertId());
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }
750936
public function customFieldsCreate($entity, $customField)
    {
        if (!count($customField) ||
            empty($customField['code']) ||
            empty($customField['name']) ||
            empty($customField['type'])
        ) {
            throw new \InvalidArgumentException(
                'Parameter `customField` must contain a data & fields `code`, `name` & `type` must be set'
            );
        }

        if (empty($entity) || !in_array($entity, ['customer', 'order'])) {
            throw new \InvalidArgumentException(
                'Parameter `entity` must contain a data & value must be `order` or `customer`'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            "/custom-fields/$entity/create",
            "POST",
            ['customField' => json_encode($customField)]
        );
    }
1257242
public function createCriteria(array $options = [], $persistent = false)
    {
        $componentId = isset($options['componentId']) ? $options['componentId'] : null;
        $pager = isset($options['pager']) ? $options['pager'] : [];
        $filter = isset($options['filter']) ? $options['filter'] : null;
        $sorter = isset($options['sorter']) ? $options['sorter'] : [];

        return new DisplayCriteria(
            $this->createPager($componentId, $pager, $persistent),
            $this->createSorter($componentId, $sorter, $persistent),
            $this->createFilter($componentId, $filter, $persistent)
        );
    }
218569
private function prepareAttributes($attributes = array())
    {
        if (!is_array($attributes)) {
            throw new InvalidArgumentException("[ImBundle] format attributes must be an array, recieved: " . var_export($attributes, true));
        }
        $result = "";
        foreach ($attributes as $key => $value) {
            if ($key === null || $key === "") {
                $result .= " " . $value;
            } else {
                $result .= " -" . $key;
                if ($value != "") {
                    $result .= " \"" . $value . "\"";
                }
            }
        }

        return $result;
    }
652847
public function newModelInstance($attributes = [])
    {
        return \tap(parent::newModelInstance($attributes), function ($model) {
            $model->setTenantor($this->tenantor);
        });
    }
132553
public function newInstance($attributes = array(), $exists = false)
	{
		// This method just provides a convenient way for us to generate fresh model
		// instances of this current model. It is particularly useful during the
		// hydration of new objects via the Eloquent query builder instances.
		$model = new static((array) $attributes);

		$model->exists = $exists;

		return $model;
	}