Make model.

@param string $slug
@param array $arguments

@return self
436268
public function make($slug, array $arguments = [])
    {
        $this->setSlug($slug);
        $this->setArguments($arguments);
        $this->setSingular($this->getArgument('title'));
        $this->setPlural($this->getArgument('title'));
        $this->setFingerprint();

        return $this;
    }
418807
public function make(array $args = array()) {
        $userModel = new Model_User();
        if (!empty($args)) {
            $id = $args[0];
        } else {
            $id = Garp_Cli::prompt('What is the id or email address of the user?');
        }
        $select = $userModel->select();
        if (is_numeric($id)) {
            $filterColumn = 'id';
        } else {
            $filterColumn = 'email';
        }
        $select->where($filterColumn . ' = ?', $id);
        $user = $userModel->fetchRow($select);
        if (!$user) {
            Garp_Cli::errorOut('Error: could not find user with ' . $filterColumn . ' ' . $id);
        } else {
            $user->role = 'admin';
            if ($user->save()) {
                // For completeness sake, check if the user has an AuthLocal
                // record. We disregard the fact wether the user already has any
                // of the other Auth- records.
                $authLocalModel = new Model_AuthLocal();
                $authLocalRecord = $authLocalModel->fetchRow(
                    $authLocalModel->select()->where('user_id = ?', $user->id)
                );
                if (!$authLocalRecord) {
                    $newAuthLocalData = array(
                        'password' => trim(Garp_Cli::prompt('Choose a password:')),
                        'user_id'  => $user->id
                    );
                    $authLocalModel->insert($newAuthLocalData);
                }
                Garp_Cli::lineOut(
                    'User with ' . $filterColumn . ' ' . $id .
                    ' is now administrator'
                );
            } else {
                Garp_Cli::errorOut(
                    'Error: could not make user with ' . $filterColumn . ' ' . $id .
                    ' administrator'
                );
            }
        }
    }
1071181
protected function chainAdd($method, $arguments = [])
    {
        $this->chain[] = [
            'method' => $method,
            'arguments' => $arguments,
        ];
        if ($this->promise !== null) {
            $chain = $this->chain;
            $this->chain = [];
            static::chainApply($this->promise, $chain);
            return $this->promise;
        }
        return $this;
    }
1363602
public function makeClass($alias, array $arguments)
    {
        $reflection = new \ReflectionClass($this->getAlias($alias));

        return $reflection->newInstanceArgs($arguments);
    }
238077
public function create($class, array $arguments = [])
    {
        $instanceType = $this->getInstanceType($class);
        $instanceArguments = $this->getInstanceArguments($class, $arguments);
        $reflection = new \ReflectionClass($instanceType);
        $constructor = $reflection->getConstructor();

        if (null === $constructor) {
            $instance = new $instanceType();
        } else {
            $args = $this->resolveArguments($constructor, $instanceArguments);
            $instance = $reflection->newInstanceArgs($args);
        }

        return $instance;
    }
965157
public function scope(string $scope, ...$arguments)
	{
		$this->model->{Str::underscored2camel($scope) . 'Scope'}(...array_merge([$this], $arguments));

		return $this;
	}
1277373
public function pipe($callback, ...$arguments)
    {
        if (! is_callable($callback)) {
            return new PipeProxy($this, $callback);
        }

        // Call the piped method
        $this->value = $callback(...$this->addValueToArguments($arguments));

        // Allow method chaining
        return $this;
    }
1033763
public function form(string $slug, array $args = []): Classes\SCore\PostMetaBoxForm
    {
        return $this->App->Di->get(Classes\SCore\PostMetaBoxForm::class, compact('slug', 'args'));
    }
844385
protected function makeSlugUnique($slug)
    {
        $i = 1;
        $slugIsUnique = false;

        // get existing slugs (1 db query)
        $list = $this->getExistingSlugs($slug);

        // slug is already unique
        if ($list->count() === 0) {
            return $slug;
        }

        // collection to array
        if (!is_array($list)) {
            $list = $list->toArray();
        }

        // loop through the list and add suffix
        while (!$slugIsUnique) {
            $uniqueSlug = $slug . $this->slugOptions->slugSeparator . ($i++);
            if (!in_array($uniqueSlug, $list)) {
                $slugIsUnique = true;
            }
        }

        return $uniqueSlug;
    }
823735
public function invokeWith($arguments = [])
    {
        $this->closeRule();

        if (empty($this->rules)) {
            $defaultAnswerCallback = $this->defaultAnswerCallback;
            $defaultAnswerCallback($this);
            $this->closeRule();
        }

        if ($arguments instanceof Arguments) {
            $argumentsArray = $arguments->all();
        } else {
            $argumentsArray = $arguments;
            $arguments = new Arguments($arguments);
        }

        foreach ($this->rules as $rule) {
            if (
                $this->matcherVerifier
                    ->matches($rule->criteria(), $argumentsArray)
            ) {
                break;
            }
        }

        $answer = $rule->next();

        foreach ($answer->secondaryRequests() as $request) {
            $this->invoker->callWith(
                $request->callback(),
                $request->finalArguments($this->self, $arguments)
            );
        }

        $request = $answer->primaryRequest();

        return $this->invoker->callWith(
            $request->callback(),
            $request->finalArguments($this->self, $arguments)
        );
    }
410643
protected function makeSlugUnique(string $slug, array $config, string $attribute): string
    {
        if (!$config['unique']) {
            return $slug;
        }

        $separator = $config['separator'];

        // find all models where the slug is like the current one
        $list = $this->getExistingSlugs($slug, $attribute, $config);

        // if ...
        // 	a) the list is empty, or
        // 	b) our slug isn't in the list
        // ... we are okay
        if (
            $list->count() === 0 ||
            $list->contains($slug) === false
        ) {
            return $slug;
        }

        // if our slug is in the list, but
        // 	a) it's for our model, or
        //  b) it looks like a suffixed version of our slug
        // ... we are also okay (use the current slug)
        if ($list->has($this->model->getKey())) {
            $currentSlug = $list->get($this->model->getKey());

            if (
                $currentSlug === $slug ||
                strpos($currentSlug, $slug) === 0
            ) {
                return $currentSlug;
            }
        }

        $method = $config['uniqueSuffix'];
        if ($method === null) {
            $suffix = $this->generateSuffix($slug, $separator, $list);
        } elseif (is_callable($method)) {
            $suffix = $method($slug, $separator, $list);
        } else {
            throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.');
        }

        return $slug . $separator . $suffix;
    }
91979
public function make(string $namespace, array $arguments = [])
    {
        $class = $this->getClassNameFromNamespace($namespace);
        /*
         * If instance of the class already created and stored into
         * stack then simply return from here
         */
        if ($this->has($class)) {
            return $this->get($class);
        }
        $reflectionClass = $this->reflection->setClass($namespace)->getReflectionClass();
        $this->throwExceptionIfNotInstantiable($namespace, $reflectionClass);

        $constructor = null;
        $constructorArgsCount = 0;
        list($constructor, $constructorArgsCount) = $this->getConstructorArgs($reflectionClass, $constructorArgsCount);

        // if class does not have explicitly defined constructor or constructor
        // does not have parameters get the new instance
        if (!isset($constructor) && is_null($constructor) || $constructorArgsCount < 1) {
            return $this[$class] = $reflectionClass->newInstance();
        }

        $dependencies = $constructor->getParameters();
        $constructorArgs = $this->createMethodArgument($dependencies, $arguments);

        return $this[$class] = $reflectionClass->newInstanceArgs($constructorArgs);
    }
823823
private function make($slug, array $arguments = [])
    {
        $thumbnail = $this->container->make(Thumbnail::class);

        $thumbnail
            ->setSlug($slug)
            ->setArguments($arguments)
            ->dispatch();

        return $this->hang($thumbnail);
    }
424931
public function generate(array $args = array()) {
        if (empty($args)) {
            $this->help();
            return false;
        }
        $modelName = $args[0];
        if (strpos($modelName, '_') === false) {
            $modelName = 'Model_' . $modelName;
        }
        $overwrite = !empty($args[1]) ? $args[1] : false;

        $model = new $modelName();
        // No reason to cache queries. Use live data.
        $model->setCacheQueries(false);

        // Fetch Sluggable thru the model as to use the right slug-configuration
        list($sluggable, $model) = $this->_resolveSluggableBehavior($model);
        if (is_null($sluggable)) {
            Garp_Cli::errorOut('This model is not sluggable.');
            return false;
        }

        // Array to record fails
        $fails = array();
        $records = $model->fetchAll();
        foreach ($records as $record) {
            if (!$overwrite && $record->slug) {
                continue;
            }
            // Mimic a beforeInsert to create the slug in a separate array $data
            $args = array($model, $record->toArray());
            $sluggable->beforeInsert($args);

            // Since there might be more than one changed column, we use this loop
            // to append those columns to the record
            foreach ($args[1] as $key => $value) {
                if ($value != $record->{$key}) {
                    $record->{$key} = $value;
                }
            }

            // Save the record with its slug
            if (!$record->save()) {
                $pk = implode(', ', (array)$record->getPrimaryKey());
                $fails[] = $pk;
            }
        }

        Garp_Cli::lineOut('Done.');
        if (count($fails)) {
            Garp_Cli::errorOut(
                'There were some failures. ' .
                'Please perform a manual check on records with the following primary keys:'
            );
            Garp_Cli::lineOut(implode("\n-", $fails));
        }
        return true;
    }
1040877
public function listen($slug, $action, array $arguments = [])
    {
        $ajax = $this->container->make(Ajax::class)
            ->setSlug($slug)
            ->setAction($action)
            ->setArguments($arguments)
            ->dispatch();

        return $this->actions->set($ajax->getSlug(), $ajax);
    }
57041
protected function createInputFromArguments(array $arguments)
    {
        return tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {
            if ($input->hasParameterOption(['--no-interaction'], true)) {
                $input->setInteractive(false);
            }
        });
    }
1212545
public function make($class, $type, $slug, $arguments = [])
    {
        $field = $this->container->make($class);

        $field
            ->setType($type)
            ->setSlug($slug)
            ->setArguments($arguments)
            ->boot();

        return $field;
    }