Creates a new file link.

@param  string  $fileId
@param  array  $attributes
@return array
168342
public function create($fileId, array $attributes = [])
    {
        $attributes = array_merge($attributes, [
            'file' => $fileId,
        ]);

        return $this->_post("file_links", $attributes);
    }
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();
    }
961501
public function attach($id, array $attributes = [], $touch = true)
    {
        // Here we will insert the attachment records into the pivot table. Once we have
        // inserted the records, we will touch the relationships if necessary and the
        // function will return. We can parse the IDs before inserting the records.
        $this->newPivotStatement()->insert($this->formatAttachRecords(
            $this->parseIds($id), $attributes
        ));

        if ($touch) {
            $this->touchIfTouching();
        }
    }
131703
public function getAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
    {
        $select = $this->connection->select();

        // The field modelizing the link between entity table and attribute values table. Either row_id or entity_id.
        $linkField = $this->getEntityMetaData($this->getEntityTypeId())->getLinkField();

        // The legacy entity_id field.
        $entityIdField = $this->getEntityMetaData($this->getEntityTypeId())->getIdentifierField();

        $joinStoreValuesConditionClauses = [
            "t_default.$linkField = t_store.$linkField",
            't_default.attribute_id = t_store.attribute_id',
            't_store.store_id= ?',
        ];

        $joinStoreValuesCondition = $this->connection->quoteInto(
            implode(' AND ', $joinStoreValuesConditionClauses),
            $storeId
        );

        $select->from(['entity' => $this->getEntityMetaData($this->getEntityTypeId())->getEntityTable()], [$entityIdField])
            ->joinInner(
                ['t_default' => $tableName],
                new \Zend_Db_Expr("entity.{$linkField} = t_default.{$linkField}"),
                ['attribute_id']
            )
            ->joinLeft(['t_store' => $tableName], $joinStoreValuesCondition, [])
            ->where('t_default.store_id=?', 0)
            ->where('t_default.attribute_id IN (?)', $attributeIds)
            ->where("entity.{$entityIdField} IN (?)", $entityIds)
            ->columns(['value' => new \Zend_Db_Expr('COALESCE(t_store.value, t_default.value)')]);

        return $this->connection->fetchAll($select);
    }
715828
public function createFile(
        FolderInterface $targetFolder,
        FileSourceInterface $fileSource,
        array $attributes,
        $userId)
    {
        $hash = $this->driver->getHashCalculator()->fromFileSource($fileSource);

        $fileClass = $this->driver->getFileClass();
        $file = new $fileClass();
        /* @var $file FileInterface */
        $file
            ->setVolume($this)
            ->setId(UuidUtil::generate())
            ->setFolder($targetFolder)
            ->setCreatedAt(new \DateTime())
            ->setCreateUserId($userId);

        $this->applyFile($file, 1, $fileSource->getName(), $fileSource->getMimeType(), $fileSource->getSize(), $hash, $attributes, $file->getCreateUserId(), $file->getCreatedAt());

        $event = new CreateFileEvent($file, $fileSource);
        if ($this->eventDispatcher->dispatch(VolumeEvents::BEFORE_CREATE_FILE, $event)->isPropagationStopped()) {
            throw new IOException("Create file {$file->getName()} failed.");
        }

        $this->driver->createFile($file, $fileSource);

        $event = new FileEvent($file);
        $this->eventDispatcher->dispatch(VolumeEvents::CREATE_FILE, $event);

        if ($this->hasFeature('versions')) {
            $this->createFileVersion($file, $fileSource, $attributes, $userId);
        }

        return $file;
    }
824592
protected function createData($mode, $content = null, array $attributes = array())
    {
        $data               = array();

        $data['mode']       = $mode;
        $data['content']    = $content;
        $data['attributes'] = array_merge($attributes, array('type' => 'text/javascript'));

        return $data;
    }
730788
public function fileUrl($attribute, $file = null)
    {
        $path = $this->templatePath($attribute, $file);
        return Yii::getAlias($this->fileOption($attribute, 'baseUrl')) . $path;
    }
434629
public function create(array $attributes)
    {
        $folder = new Folder($attributes);

        $folder->validateRequired();

        $folder->setAttribute('container', array_reverse($folder->getAttribute('container')));

        $add = [];

        $add['objectClass'] = 'organizationalUnit';
        $add['OU'] = $folder->getAttribute('ou_name');

        $containers = 'OU='.implode(',OU=', $folder->getAttribute('container'));

        $dn = 'OU='.$add['OU'].', '.$containers.$this->adldap->getBaseDn();

        return $this->connection->add($dn, $add);
    }
74955
public function javascriptIncludeTag($filename, $attributes)
    {
        $webPaths = array();
        $absolutePaths = $this->parser->javascriptFiles($filename);

        foreach ($absolutePaths as $absolutePath)
        {
            $webPaths[] = $this->parser->absolutePathToWebPath($absolutePath);
        }

        $config = $this->getConfig();
        $composer = $config['javascript_include_tag'];

        return $composer->process($webPaths, $absolutePaths, $attributes);
    }
817996
public function node($id, array $attributes = array())
    {
        $this->instructions[] = new Node($id, $attributes, $this);

        return $this;
    }
393100
public function make(UploadedFile $file, array $attributes = [])
    {
        $image = app('image')
            ->make($file->getPathname())
            ->resize(
                config('media.maxwidth', 2560),
                config('media.maxheight', null),
                function ($constraint) {
                    if (config('media.aspectratio', true)) {
                        $constraint->aspectRatio();
                    }
                    if (config('media.upsize', true)) {
                        $constraint->upsize();
                    }
                }
            )
            ->encode(null, config('media.compression', 80));

        return $this->save($file->getClientOriginalName(), $image, $attributes);
    }
425018
protected function createAttachRecords($ids, array $attributes)
	{
		$records = array();

		$timed = ($this->hasPivotColumn($this->createdAt()) ||
			      $this->hasPivotColumn($this->updatedAt()));

		// To create the attachment records, we will simply spin through the IDs given
		// and create a new record to insert for each ID. Each ID may actually be a
		// key in the array, with extra attributes to be placed in other columns.
		foreach ($ids as $key => $value)
		{
			$records[] = $this->attacher($key, $value, $attributes, $timed);
		}

		return $records;
	}
1061853
public function imageTag($filename, $attributes)
    {
        $absolutePath = $this->file($filename);
        $webPath = $this->parser->absolutePathToWebPath($absolutePath);

        $config = $this->getConfig();
        $composer = $config['image_tag'];

        return $composer->process(array($webPath), array($absolutePath), $attributes);
    }
413315
public static function create(array $attributes = [])
    {
        $site_id = site()->id;

        $contact = new static;

        $fillable = $contact->getFillable();

        foreach (array_only($attributes, $fillable) as $key => $value) {

            if  (is_array($value)) {
                $value = json_encode($value);
            }
            $row = Setting::privateOnly()->firstOrNew(compact('key', 'site_id'));
            $row->fill(compact('value'));
            $row->save();
        }

        return true;
    }
733219
public function createFile($filePath, $folderId)
    {
        $fileHandler = $this->container->get('kunstmaan_media.media_handlers.file');

        // Get file from FilePath.
        $data = new File($filePath, true);

        /** @var $media Media */
        $media = $fileHandler->createNew($data);
        /** @var $folder Folder */
        $folder = $this->folderRepository->getFolder($folderId);

        $media->setFolder($folder);

        $fileHandler->prepareMedia($media);
        $fileHandler->updateMedia($media);
        $fileHandler->saveMedia($media);

        $this->em->persist($media);
        $this->em->flush();

        return $media;
    }
112085
public function getDocument($attributes = [], $onlyUrl = false, $modelSlug = null, $relation = null)
    {
        $this->setAttributes($modelSlug,'file');
        $file = $this->getFile();

        if (is_null($file)) {
            return '';
        }
        $src = $this->getFileDownloadSrc($file, $relation);
        $attr = $this->getHTMLAttributes($attributes);
        return $onlyUrl ? asset($src) : '<a href="'.asset($src).'" '.$attr.'> ' . $file . '</a>';
    }
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;
    }