Get or create row

@param array $input The input data.
@return \Illuminate\Database\Eloquent\Model
438795
public function firstOrCreate(array $input)
    {
        $this->cache->tags($this->getModel())->flush();
        return $this->repository->firstOrCreate($input);
    }
406218
protected function resolve(Input $input): Input
    {
        $this->call($input->value());
        $input->ignore();

        return $input;
    }
363526
public function delete(array $input)
  {
    $info = false;

    $this->DB->transaction(function() use ($input, &$info)
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');
      $ids = $this->getAccountChildrenIds($input['id']);

      array_push($ids, $input['id']);

      if($this->JournalEntry->byAccountIds($ids)->count() > 0)
      {
        $info = $this->Lang->get('decima-accounting::account-management.accountValidationMessage');
        return;
      }

      $this->Account->byIds($ids)->each(function($Account) use ($loggedUserId, $organizationId)
      {
        $Journal = $this->Journal->create(array('journalized_id' => $Account->id, 'journalized_type' => $this->Account->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
        $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::account-management.accountDeletedAccount', array('account' => $Account->key . ' ' . $Account->name)), $Journal));
      });

      $this->Account->delete($ids);
    });

    if(!$info)
    {
      return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage')));
    }
    else
    {
      return json_encode(array('info' => $info));
    }
  }
855846
public function input($input = null, $default = null)
    {
        // Get all inputs
        $inputs = array_merge($this->getInputs(), $this->additionalInputs);

        // Exclude reserved inputs
        foreach ($inputs as $key => $value) {
            if (in_array($key, $this->reserved)) {
                unset($inputs[$key]);
            }
        }

        // Return one input
        if ($input) {
            return isset($inputs[$input])? $inputs[$input] : $default;
        }

        // Or the complete array of inputs
        return $inputs;
    }
310194
public static function build($input = null) : Response
    {
        //Is a response object already
        if ($input instanceof Response) {
            return $input;
        }

        $response = new Response();

        //View
        if ($input instanceof View) {
            $response->setBody($input->draw());
        }

        //Json
        if ($input instanceof ConvertsToJson) {
            self::createFromJsonable($response, $input);
        }

        //Array
        if (is_array($input)) {
            self::createFromArray($response, $input);
        }

        //String
        if (is_string($input)) {
            $response->setBody($input);
        }

        return $response;
    }
808913
protected function createViews($input)
    {
        if (!$this->option('without-views')) {
            $this->call(
                'create:views',
                [
                    'model-name' => $input->modelName,
                    '--resource-file' => $input->resourceFile,
                    '--views-directory' => $input->viewsDirectory,
                    '--routes-prefix' => $input->prefix,
                    '--layout-name' => $input->layoutName,
                    '--template-name' => $input->template,
                    '--force' => $input->force,
                ]
            );
        }

        return $this;
    }
470556
public function process($model, $input)
    {
        $column = $this->getColumn();

        $model->{$this->getColumn()} = isset($input[$column]) ?: false;

        return $model;
    }
135266
public static function fetch($input): array
    {
        $output = [];
        $map = [];
        foreach ($input as $i => $row) {
            $model = '';
            foreach ($row as $key => $value) {
                if (strpos($key, '__') === 0) {
                    $model = substr($key, 2);
                    continue;
                }
                $map[$i][$model][$key] = $value;
            }
            foreach ($map[$i] as $model => &$data) {
                $data = self::createRow($model, $data);
            }
            $output[] = $map;
        }
        return $output;
    }
986867
public function process(array $input)
    {
        if (!empty($input['q'])) {
            $this->searchQuery = $input['q'];
        }
        if (!empty($input['sort'])) {
            foreach (explode(',', $input['sort']) as $sort) {
                $this->processOrderByParams($sort);
            }
        }
        $input = $this->processPageParams($input);
        foreach ($input as $key => $param) {
            if (!in_array($key, ['sort', 'page', 'per_page', 'q'], true)) {
                $this->processFilterParams($key, $param);
            }
        }
        return $this;
    }
1226462
protected function getTransformedInput($input)
	{
		$transformed = new Fluent($input);

		foreach ($this->transformInput(new Fluent($input)) as $k => $v) {
			if (array_key_exists($k, $input)) {
				if ($v instanceof \Closure) {
					$transformed[$k] = $v($input[$k]);
				} else {
					$transformed[$k] = $v;
				}
			}
		}

		return $transformed;
	}
906631
public function build($input)
    {
        $scaffold = new Scaffold($this->blueprint->class, $input);
        $this->applyInstructions($scaffold, Instruction::PHASE_PRE_INST);
        $this->makeInstance($scaffold);
        $this->applyInstructions($scaffold, Instruction::PHASE_POST_INST);
        $this->assignProperties($scaffold);
        $this->applyInstructions($scaffold, Instruction::PHASE_FINAL);
        return $scaffold->instance;
    }
560484
public function serialise($input)
    {
        $writer = Writer::createFromString('');

        if (is_array(reset($input))) {
            $writer->insertOne(array_keys(reset($input)));
        } else {
            $writer->insertOne(array_keys($input));
        }

        if (is_array(reset($input))) {
            $writer->insertAll($input);
        } else {
            $writer->insertOne($input);
        }

        return $writer->__toString();
    }
749632
public static function createFromArray(array $input)
    {
        if (3 != count($input)) {
            throw new InvalidArgumentException(
                sprintf("%s() expects an array with exactly three elements", __METHOD__)
            );
        }
        if (array_key_exists('A', $input) && array_key_exists('B', $input) && array_key_exists('C', $input)) {
            return new self($input['A'], $input['B'], $input['C']);
        }
        return new self(array_shift($input), array_shift($input), array_shift($input));
    }
764526
public static function createFromArray(array $input)
    {
        if (2 != count($input)) {
            throw new InvalidArgumentException(
                sprintf("%s() expects an array with exactly two elements", __METHOD__)
            );
        }
        if (array_key_exists('start', $input) && array_key_exists('end', $input)) {
            $start = $input['start'];
            $end   = $input['end'];
        } else {
            $start = array_shift($input);
            $end   = array_shift($input);
        }
        if (is_array($start)) {
            $start = Point::createFromArray($start);
        }
        if (is_array($end)) {
            $end = Point::createFromArray($end);
        }
        return new static($start, $end);
    }
96031
public function fetch(Input $input)
    {
        return $this->bus->handle(
            $this->messageCreator->create($this->query, $input)
        );
    }
335233
public function update(array $input = [])
    {
        DB::beginTransaction();

        try {
            LaravelEvent::fire(static::$name.'.updating', $this);
            $this->beforeUpdate($input);
            $return = parent::update($input);
            $this->afterUpdate($input, $return);
            LaravelEvent::fire(static::$name.'.updated', $this);

            DB::commit();
        } catch (\Exception $e) {
            DB::rollBack();
            throw $e;
        }

        return $return;
    }
661556
public function prepare($input)
    {
        $form = $this->buildEmbeddedForm();

        return $form->setOriginal($this->original)->prepare($input);
    }