public function q(Request $request)
 {
     $search = $request->input("q");
     //todo: parse 'q' in separate class and return an array of parameters.
     //   See: https://developer.github.com/v3/search/#search-repositories
     $matches = [];
     //look specifically for field limiter 'in'
     $match = preg_match('/^(?<q>.*)\\bin:(?<in>.*)/us', $search, $matches[]);
     if ($match) {
         //just look for uri
         if (isset($matches[0]['in'])) {
             $fields = explode(',', $matches[0]['in']);
             foreach ($fields as $field) {
                 if ('uri' == $field) {
                     //lookup the uri in elements
                     $element = $this->elementRepository->findBy('uri', $matches[0]['q']);
                     if ($element) {
                         return $this->sendResponse($element->toArray(), "element found");
                     }
                     //lookup the uri in concepts
                     $concept = $this->conceptRepository->findBy('uri', $matches[0]['q']);
                     if ($concept) {
                         return $this->sendResponse($concept->toArray(), "concept found");
                     }
                 } else {
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Remove the specified Element from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $element = $this->elementRepository->find($id);
     if (empty($element)) {
         Flash::error('Element not found');
         return redirect(route('elements.index'));
     }
     $this->elementRepository->delete($id);
     Flash::success('Element deleted successfully.');
     return redirect(route('elements.index'));
 }
 /**
  * Remove the specified Element from storage.
  * DELETE /elements/{id}
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $this->elementRepository->apiDeleteOrFail($id);
     return $this->sendResponse($id, "Element deleted successfully");
 }