Searches the storage for data defined by ID and/or attributes.

@param string $id The item ID
@param array(string=>string) $attributes Attributes describing the data
@return array(mixed)
541368
protected function search( $id = null, $attributes = array() )
    {
        // Grabs the identifier registry
        $this->fetchSearchRegistry();

        // Grabs the $location
        $location = $this->properties['location'];

        // Finds all in case of empty $id and $attributes
        if ( $id === null
             && empty( $attributes )
             && isset( $this->searchRegistry[$location] )
             && is_array( $this->searchRegistry[$location] ) )
        {
            $itemArr = array();
            foreach ( $this->searchRegistry[$location] as $idArr )
            {
                foreach ( $idArr as $registryObj )
                {
                    if ( !is_null( $registryObj->id ) )
                    {
                        $itemArr[] = array( $registryObj->id, $registryObj->attributes, $registryObj->identifier );
                    }
                }
            }
            return $itemArr;
        }

        $itemArr = array();
        // Makes sure we've seen this ID before
        if ( isset( $this->searchRegistry[$location][$id] )
             && is_array( $this->searchRegistry[$location][$id] ) )
        {
            foreach ( $this->searchRegistry[$location][$id] as $identifier => $dataArr )
            {
                if ( $this->fetchData( $identifier ) !== false )
                {
                    $itemArr[] = array( $id, $attributes, $identifier );
                }
            }
        }
        else
        {
            // Finds cache items that fit our description
            if ( isset( $this->searchRegistry[$location] )
                 && is_array( $this->searchRegistry[$location] ) )
            {
                foreach ( $this->searchRegistry[$location] as $id => $arr )
                {
                    foreach ( $arr as $identifier => $registryObj )
                    {
                        if ( count( array_diff_assoc( $attributes, $registryObj->attributes ) ) === 0 )
                        {
                            $itemArr[] = array(
                                $registryObj->id,
                                $registryObj->attributes,
                                $registryObj->identifier
                            );
                        }
                    }
                }
            }
        }
        return $itemArr;
    }
606872
public function store($attributes = [])
    {
        // Set the attributes
        $attributes = (!empty($attributes))? $attributes : $this->app->request->input();

        // Create the record
        $result = $this->model->create($attributes);

        // Return results
        return [
            'success' => true,
            'id' => $result['id'],
            'data' => $result
        ];
    }
186175
public function create($id, array $attributes)
    {
        $typeModelName = $this->getTypeModelName();

        $nodeType = $typeModelName::findOrFail($id);

        $nodeField = $nodeType->addField($attributes);

        $this->builderService->buildField(
            $nodeField->getName(),
            $nodeField->getType(),
            $nodeField->isIndexed(),
            $nodeType->getName(),
            $nodeType
        );

        return $nodeField;
    }
626021
public function fetchById($id)
    {
        $data = parent::fetchById($id);
        if ($data) {
            foreach (array_keys($this->subAttributeList) as $subKey) {
                $data[$subKey] = $this->fetchSubAttributeById($id, $subKey);
            }
        }
        return $data;
    }
1341831
private function getDefinition($id)
    {
        $id = $this->getDefinitionId($id);

        return null === $id ? null : $this->container->getDefinition($id);
    }
252852
public function find($id, $properties = array('*')) {
        // If the dev did not specify the $id as an int it would break
        // so we cast it anyways.

        if (is_array($id)) {
            return $this->findMany(array_map(function($id) {
                                return (int) $id;
                            }, $id), $properties);
        } else {

            $id = $id;
        }

        $this->query->where($this->model->getKeyName(), '=', $id);

        return $this->first($properties);
    }
1207821
public function findInResById($id)
    {
        $id = Lib::toInteger($id);
        $this->ensureIdIsInteger($id);

        // Sestaveni URL
        $url = $this->wrapUrl(sprintf(self::URL_RES, $id));

        $cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
        $cachedFile = $this->cacheDir.'/res_'.$cachedFileName;
        $cachedRawFile = $this->cacheDir.'/res_raw_'.$cachedFileName;

        if (is_file($cachedFile)) {
            return unserialize(file_get_contents($cachedFile));
        }

        try {
            $aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
            if ($this->debug) {
                file_put_contents($cachedRawFile, $aresRequest);
            }
            $aresResponse = simplexml_load_string($aresRequest);

            if ($aresResponse) {
                $ns = $aresResponse->getDocNamespaces();
                $data = $aresResponse->children($ns['are']);
                $elements = $data->children($ns['D'])->Vypis_RES;

                if (strval($elements->ZAU->ICO) === $id) {
                    $record = new AresRecord();
                    $record->setCompanyId(strval($id));
                    $record->setTaxId($this->findVatById($id));
                    $record->setCompanyName(strval($elements->ZAU->OF));
                    $record->setStreet(strval($elements->SI->NU));
                    $record->setStreetHouseNumber(strval($elements->SI->CD));
                    $record->setStreetOrientationNumber(strval($elements->SI->CO));
                    $record->setTown(strval($elements->SI->N));
                    $record->setZip(strval($elements->SI->PSC));
                } else {
                    throw new AresException('IČ firmy nebylo nalezeno.');
                }
            } else {
                throw new AresException('Databáze ARES není dostupná.');
            }
        } catch (\Exception $e) {
            throw new AresException($e->getMessage());
        }
        file_put_contents($cachedFile, serialize($record));

        return $record;
    }
1144126
public static function getIdValue(array $id) 
    {
        self::formatScalarValues($id);
        if (\is_array($id)) {
            RecursiveDeleteHelper::deleteKeys($id, [Serializer::CLASS_IDENTIFIER_KEY]);
        }

        return $id;
    }
12644
private function sync($id, $attributes)
    {
        // Return if the ID is invalid, or attributes is not an array
        if (!isset($id) || !isset($attributes) || empty($attributes)) {
            return $this;
        }

        // Return if there are no relationships of that type
        if (!isset($this->relationships['belongsToMany']) || empty($this->relationships['belongsToMany'])) {
            return $this;
        }

        // Sync each relationship
        foreach ($this->relationships['belongsToMany'] as $join) {

            // The sync option has to be true, the related attribute an array
            if (isset($join['sync']) && $join['sync'] && isset($attributes[$join['alias']]) && is_array($attributes[$join['alias']])) {

                // Delete old values
                $delete = $this->db()->table($join['pivot'])->where($join['localKey'], $id, '=')->delete();

                // Insert new values
                foreach ($attributes[$join['alias']] as $value) {
                    $this->db()->table($join['pivot'])->insert([$join['localKey'] => $id, $join['foreignKey'] => $value]);
                }
            }
        }

        // Return model instance
        return $this;
    }
627550
public function update(array $attributes = [], $id = null)
    {
        // This allows for update based on the primary key
        if ($id && $this->exists === false) {
            $this->setAttribute($this->getKeyName(), $id);
            $this->exists = true;
        }

        $this->syncOriginal();

        return $this->fill($attributes)->save();
    }
692134
public function update($id, array $attributes = [])
    {
        // Find the given instance
        $updated  = false;
        $instance = $id instanceof Model ? $id : $this->find($id);

        if ($instance) {
            // Fill instance with data
            $instance->fill($attributes);

            // Save the instance
            $updated = $instance->save();

            // Fire the updated event
            $this->getContainer('events')->fire($this->getRepositoryId().'.entity.updated', [$this, $instance]);
        }

        return [
            $updated,
            $instance,
        ];
    }
894733
public static function id2dir($id = null) {
        if ($id === null) {
            return self::$maps ['id2dir'];
        }
        if (isset (self::$maps ['id2dir'] [ $id ])) {
            return self::$maps ['id2dir'] [ $id ];
        } else {
            return $id;
        }
    }
248163
public function update($id, array $attributes)
    {
        $model = $this->model->findOrFail($id);

        $this->validation()->validate('update', array_merge($attributes, [$this->model->getKeyName() => $id]));

        $model->fill($attributes);

        $model->save();

        return $model;
    }
328579
public function get(string $id = null): array
    {
        if ($this->has($id)) {
            return $this->cache[$id];
        }

        return [];
    }
932348
public function findOne($attributes, $uri)
    {
        $where      = [
            'resource' => $uri,
            'name'     => snake_case(array_get($attributes, 'name'))
        ];
        $components = $this->components->filter(function($item) use($where) {
            return $item->resource == array_get($where, 'resource') && $item->name == array_get($where, 'name');
        });
        $component = $components->count() ? $components->first() : null;
        if (!is_null($component)) {
            return array_merge($component->data, ['id' => $component->id]);
        }
        return [];
    }
532825
public function getContent($id = "")
    {
        $this->setUpList();
        return isset($this->idArray[$id]) ?
            $this->idArray[$id] :
            $this->idArray[$id] = $this->createContent($id);

    }
624522
function instance($id): array
    {
        return collect($this->find($id))
            // Filter model attributes on actual form fields
            ->only($this->getDataKeys())
            ->all();
    }