public function getDelete($referenceId)
 {
     if (!isset($referenceId)) {
         return redirect()->back();
     }
     $reference = Reference::where('id', $referenceId)->first();
     $reference->delete();
     return redirect()->back();
 }
Esempio n. 2
0
 /**
  *  Returns matches in the reference table for the given term
  *
  *  @param   string  $term  The search term
  *
  *  @return  mixed         Response or Collection depending on validation
  */
 public function getReferenceSearch($term)
 {
     // The "LIKE"-Statement in SQL just searches for the pattern
     // anywhere in, at the beginning or the end of a term.
     $references = Reference::where('title', 'LIKE', '%' . $term . '%')->orWhere('author_first', 'LIKE', '%' . $term . '%')->orWhere('author_last', 'LIKE', '%' . $term . '%')->orWhere('title', 'LIKE', '%' . $term . '%')->limit(20)->get();
     if (!$references) {
         return response()->json(['message', 'No references match your search term'], 404);
     } else {
         return $references;
     }
 }