Get a dictionary keyed by primary keys.

@param  \Fly\Support\Collection  $collection
@return array
550616
public function getDictionary($collection)
	{
		$dictionary = array();

		foreach ($collection as $value)
		{
			$dictionary[$value->getKey()] = $value;
		}

		return $dictionary;
	}
89804
public static function get_metadata(collection $collection) : collection {
        $collection->add_subsystem_link('core_completion', [], 'privacy:metadata:completionsummary');
        $collection->add_subsystem_link('core_favourites', [], 'privacy:metadata:favouritessummary');
        $collection->add_user_preference('coursecat_management_perpage', 'privacy:perpage');
        return $collection;
    }
283386
public static function get_metadata(collection $collection) : collection {
        $completedfields = [
            'userid' => 'privacy:metadata:completed:userid',
            'timemodified' => 'privacy:metadata:completed:timemodified',
            'anonymous_response' => 'privacy:metadata:completed:anonymousresponse',
        ];

        $collection->add_database_table('feedback_completed', $completedfields, 'privacy:metadata:completed');
        $collection->add_database_table('feedback_completedtmp', $completedfields, 'privacy:metadata:completedtmp');

        $valuefields = [
            'value' => 'privacy:metadata:value:value'
        ];

        $collection->add_database_table('feedback_value', $valuefields, 'privacy:metadata:value');
        $collection->add_database_table('feedback_valuetmp', $valuefields, 'privacy:metadata:valuetmp');

        return $collection;
    }
572712
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $order) {
            $entry = new Entry($order);

            $entry
                ->field('id')
                ->field('firstname')
                ->field('lastname')
                ->field('address1')
                ->field('address2')
                ->field('zipcode')
                ->field('city')
                ->field('country')
                ->field('phone_work')
                ->field('phone_home')
                ->field('phone_mobile')
                ->field('other_informations')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
1361547
public function bulkSave($collection = [])
    {
        $params = [];

        $defaultIndex = $this->connection->getDefaultIndex();

        foreach ($collection as $item) {
            $modelIndex = $item->getDocumentIndex();

            $params['body'][] = [
                'index' => [
                    '_id'    => $item->getKey(),
                    '_type'  => $item->getDocumentType(),
                    '_index' => $modelIndex ? $modelIndex : $defaultIndex,
                ],
            ];
            $params['body'][] = $item->getDocumentData();
        }

        return $this->connection->bulkStatement($params);
    }
1003271
private function getIds(
        $collection = null,
        $systemCollections = true,
        $types = null,
        $search = null,
        $orderBy = null,
        $orderSort = null,
        $limit = null,
        $offset = null
    ) {
        $subQuery = $this->getIdsQuery(
            $collection,
            $systemCollections,
            $types,
            $search,
            $orderBy,
            $orderSort,
            $limit,
            $offset
        );

        return $subQuery->getScalarResult();
    }
897133
public static function get($property, $collection)
    {
        if (false === self::isValid($collection)) {
            return [];
        }

        $getter = sprintf('get%s', ucfirst($property));
        $result = [];
        foreach ($collection as $entity) {
            $function = [
                $entity,
                $getter
            ];

            if (false === is_callable($function)) {
                throw new LogicException('Missing getter');
            }

            $result[] = $entity->$getter();
        }

        return $result;
    }
545889
public function formatEloquentCollection($collection)
    {
        if ($collection->isEmpty()) {
            return $this->encode([]);
        }

        $model = $collection->first();
        $key = Str::plural($model->getTable());

        if (! $model::$snakeAttributes) {
            $key = Str::camel($key);
        }

        return $this->encode([$key => $collection->toArray()]);
    }
507631
protected function removeEmpty($collection) {
        foreach ($collection as $key => $value) {
            if (empty($value)) {
                unset($collection[$key]);
            }
        }

        return $collection;
    }
1139398
protected function activeLogs(Collection $collection)
    {
        $return = [];
        foreach ($collection as $model) {
            $module = $model->component->name;
            if (!isset($return[$module][$model->name])) {
                $return[$module][$model->name] = 0;
            }
            $return[$module][$model->name] += 1;
        }
        return $return;
    }
851076
public static function get_metadata(collection $collection) : collection {
        $messageemailmessages = [
            'useridto' => 'privacy:metadata:message_email_messages:useridto',
            'conversationid' => 'privacy:metadata:message_email_messages:conversationid',
            'messageid' => 'privacy:metadata:message_email_messages:messageid',
        ];
        // Note - this data gets deleted once the scheduled task runs.
        $collection->add_database_table('message_email_messages',
            $messageemailmessages, 'privacy:metadata:message_email_messages');

        $collection->link_external_location('smtp', [
                'recipient' => 'privacy:metadata:recipient',
                'userfrom' => 'privacy:metadata:userfrom',
                'subject' => 'privacy:metadata:subject',
                'fullmessage' => 'privacy:metadata:fullmessage',
                'fullmessagehtml' => 'privacy:metadata:fullmessagehtml',
                'attachment' => 'privacy:metadata:attachment',
                'attachname' => 'privacy:metadata:attachname',
                'replyto' => 'privacy:metadata:replyto',
                'replytoname' => 'privacy:metadata:replytoname'
        ], 'privacy:metadata:externalpurpose');

        return $collection;
    }
516939
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $product) {
            $entry = new Entry($product);

            $entry
                ->field('id')
                ->field('name')
                ->field('description')
                ->field('sku')
                ->field('status')
                ->field('price')
                ->field('sale_price')
                ->field('quantity')

                ->value('image', $product->product->defaultImage())
                // ->relationshipField('product', 'Subbly\\Presenter\\V1\\ProductPresenter')

                ->dateField('created_at')
                ->dateField('updated_at')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
695100
public static function get_metadata(collection $collection) : collection {
        $statsuserdaily = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];

        $statsuserweekly = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];

        $statsusermonthly = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];
        $collection->add_database_table('stats_user_daily', $statsuserdaily, 'privacy:metadata:statssummary');
        $collection->add_database_table('stats_user_weekly', $statsuserweekly, 'privacy:metadata:statssummary');
        $collection->add_database_table('stats_user_monthly', $statsusermonthly, 'privacy:metadata:statssummary');
        return $collection;
    }
1324244
public function get($collection = "")
		{

			$documents = $this->getCursor($collection);

			$returns = array();

			if ($documents && !empty($documents)) {
				foreach ($documents as $doc) {
					$returns[] = $doc;
				}
			}

			return $returns;
		}
335547
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $product) {
            $entry = new Entry($product);

            $entry
                ->conditionalField('id', function () {
                    return Subbly::api('subbly.user')->hasAccess('subbly.backend.auth');
                })

                ->field('position')
                ->field('name')
                ->field('description')
                ->field('sku')
                ->field('status')
                ->field('price')
                ->field('sale_price')
                ->field('quantity')

                ->relationshipField('images', 'Subbly\\Presenter\\V1\\ProductImagePresenter')
                ->relationshipField('options', 'Subbly\\Presenter\\V1\\ProductOptionPresenter')
                ->relationshipField('categories', 'Subbly\\Presenter\\V1\\ProductCategoryPresenter')

                ->dateField('created_at')
                ->dateField('updated_at')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
1224695
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $category) {
            $entry = new Entry($category);

            $entry
                ->field('id')
                ->field('label')
                ->field('slug')
                ->field('parent')
                ->field('position')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
900303
protected function getModelKeysFromCollection(EntityCollection $entities)
    {
        $keyName = $this->relatedMap->getKeyName();

        return array_map(function ($m) use ($keyName) {
            return $m->$keyName;
        }, $entities);
    }