Create a new pivot attachment record.

@param int  $id
@param bool $timed

@return array
541900
protected function createAttachRecord($id, $timed)
    {
        $parentKey = $this->parentMap->getKeyName();

        $record = [];

        $record[$this->foreignKey] = $this->parent->getEntityAttribute($parentKey);

        $record[$this->otherKey] = $id;

        // If the record needs to have creation and update timestamps, we will make
        // them by calling the parent model's "freshTimestamp" method which will
        // provide us with a fresh timestamp in this model's preferred format.
        if ($timed) {
            $record = $this->setTimestampsOnAttach($record);
        }

        return $record;
    }
1145658
public function retrieveWithScheduledChanges(string $id, array $headers = [])
    {
        $url = $this->url('subscriptions/%s/retrieve_with_scheduled_changes', $id);

        return $this->get($url, [], $headers);
    }
21109
public function updateExistingPivot($id, array $attributes, $touch = true)
    {
        if ($this->using && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
            return $this->updateExistingPivotUsingCustomClass($id, $attributes, $touch);
        }

        if (in_array($this->updatedAt(), $this->pivotColumns)) {
            $attributes = $this->addTimestampsToAttachment($attributes, true);
        }

        $updated = $this->newPivotStatementForId($this->parseId($id))->update(
            $this->castAttributes($attributes)
        );

        if ($touch) {
            $this->touchIfTouching();
        }

        return $updated;
    }
1122753
public function createEditForm($id) {
        $entity = $this->read_handler->get($id);
        $edit_form = $this->form_factory->create(new Type(), $entity);

        return $edit_form;
    }
437308
public function removeScheduledChanges(string $id, array $headers = [])
    {
        $url = $this->url('subscriptions/%s/remove_scheduled_changes', $id);

        return $this->post($url, [], $headers);
    }
548874
public function createForFolder(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::POST,
            ResourceMethodEnum::CREATE_FOR_FOLDER,
            $params,
            $id
        );
    }
1238129
protected function formatAttachRecords($ids, array $attributes)
    {
        $records = [];

        $hasTimestamps = ($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->formatAttachRecord(
                $key, $value, $attributes, $hasTimestamps
            );
        }

        return $records;
    }
574109
public function buildForm($id = '', $action = '', $async = false, $fileUpload = false, $attributes = [])
    {
        // Create form control
        $form = new Form($this->getHTMLDocument(), $this, $attributes);
        $form->build($id, $action, $async, $fileUpload);

        return $form;
    }
67892
public function sync($ids, $detaching = true)
    {
        $changes = [
            'attached' => [],
            'detached' => [],
            'updated'  => [],
        ];

        $pk = $this->parent->getPk();

        $current = $this->pivot
            ->where($this->localKey, $this->parent->$pk)
            ->column($this->foreignKey);

        $records = [];

        foreach ($ids as $key => $value) {
            if (!is_array($value)) {
                $records[$value] = [];
            } else {
                $records[$key] = $value;
            }
        }

        $detach = array_diff($current, array_keys($records));

        if ($detaching && count($detach) > 0) {
            $this->detach($detach);
            $changes['detached'] = $detach;
        }

        foreach ($records as $id => $attributes) {
            if (!in_array($id, $current)) {
                $this->attach($id, $attributes);
                $changes['attached'][] = $id;
            } elseif (count($attributes) > 0 && $this->attach($id, $attributes)) {
                $changes['updated'][] = $id;
            }
        }

        return $changes;
    }
1143529
public function newPivotStatementForId($id)
    {
        return $this->newPivotQuery()->whereIn($this->relatedPivotKey, $this->parseIds($id));
    }
831614
protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
    {
        [$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);

        return array_merge(
            $this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
        );
    }
902391
public function mediatemplate($id)
    {
        $template = $this->templateManager->find($id);

        if (!$template) {
            return [];
        }

        return $template->getParameters();
    }
849813
public function attachTags(int $id, AttachRequest $request)
    {
        /** @var \Unite\Tags\HasTagsInterface $object */
        if(!$object = $this->repository->find($id)) {
            abort(404);
        }

        $data = $request->only(['tag_names']);

        $object->attachTags($data['tag_names']);

        \Cache::tags('response')->flush();

        return $this->successJsonResponse();
    }
158257
protected function baseAttachRecord($id, $timed)
    {
        $record[$this->relatedKey] = $id;

        $record[$this->foreignKey] = $this->parent->getKey();

        // If the record needs to have creation and update timestamps, we will make
        // them by calling the parent model's "freshTimestamp" method which will
        // provide us with a fresh timestamp in this model's preferred format.
        if ($timed) {
            $record = $this->addTimestampsToAttachment($record);
        }

        return $record;
    }
443482
private function processClip($id,$attributes,$offset)
	{
		return $this->processBeginClip($id,$attributes,$offset) . $this->processEndClip($id,$offset);
	}
631573
public function generate(int $id, Request $request)
    {
        /** @var \Railken\Amethyst\Managers\FileGeneratorManager */
        $manager = $this->manager;

        /** @var \Railken\Amethyst\Models\FileGenerator */
        $generator = $manager->getRepository()->findOneById($id);

        if ($generator == null) {
            return $this->not_found();
        }

        $result = $manager->generate($generator, (array) $request->input('data'));

        if (!$result->ok()) {
            return $this->error(['errors' => $result->getSimpleErrors()]);
        }

        return $this->success([]);
    }
836765
public function attach($id)
    {
        // Require there to be a parent id and a valid id for the resource
        $item = $this->findOrFail($id);

        // Do the attach
        $item->fireDecoyEvent('attaching', [$item, $this->parent]);
        $item->{$this->self_to_parent}()->attach($this->parent);
        $item->fireDecoyEvent('attached', [$item, $this->parent]);

        // Return the response
        return Response::json();
    }