public function references(ModelMetaReferenceRequest $request)
    {
        $modelClass = $request->input('model');
        $type       = $request->input('type');
        $key        = $request->input('key');

        $referenceData = $this->getModelMetaReferenceData($modelClass, $type, $key);

        if ( ! $referenceData) {
            // @codeCoverageIgnoreStart
            abort(404, "Could not determine reference for {$modelClass} (type: {$type}, key: {$key})");
            // @codeCoverageIgnoreEnd
        }

        $search = $request->input('search');

        if (is_array($referenceData)) {

            $references = [];

            foreach ($referenceData as $singleReferenceData) {
                $references[ $singleReferenceData->model ] = $this->getReferencesByMetaData($singleReferenceData, $search);
            }

        } else {
            $references = $this->getReferencesByMetaData($referenceData, $search);
        }

        // For now, always return json data, even if the request was not AJAX.
        return response()->json($references);
    }