/** * get keys for (a set of) document types */ public function postKeys() { $documents = explode("|", Input::get('documents')); $searchComponent = new MediaSearchComponent(); $keys = $searchComponent->getKeys($documents); asort($keys); $formats = $searchComponent->getFormats(); // default columns $default = ['_id', 'documentType', 'title', 'created_at', 'project', 'user_id']; // default visible columns return ['log' => $documents, 'keys' => $keys, 'formats' => $formats, 'default' => $default]; }
/** * get keys for (a set of) selected document types */ public function postKeys() { // get the document types $documents = explode("|", Input::get('documents')); $searchComponent = new MediaSearchComponent(); // store all keys in this array $docKeys = []; // go through each selected document type and get the keys foreach ($documents as $type) { // skip if value is empty if ($type == "") { continue; } elseif ($type == "all") { $units = Unit::select('content')->get(); } else { // split the document type string so that we can get the project name from it. $type = explode('__', $type); // get the content of the units for this document type in this project // if the load on the system is too high limit this to e.g. 100 random units. $units = Unit::select('content')->where('project', $type[0])->where('documentType', $type[1])->get(); } // get the keys for the units in this document type foreach ($units as $unit) { $unit->attributesToArray(); $keys = $searchComponent->getKeys($unit['attributes']); $docKeys = array_unique(array_merge($docKeys, $keys)); } } // asort($keys); return $docKeys; }