public function getList(Request $request) { if (isset($request->search) && !empty($request->search)) { $search = $request->search; } else { $search = ''; } $objectList = Patient::orderBy('created_at', 'asc')->take(10)->get(); if (isset($search) && !empty($search)) { $objectList = Patient::whereRaw('upper(lastname) like ? or upper(firstname) like ?', array('%' . strtoupper($search) . '%', '%' . strtoupper($search) . '%'))->orderBy('created_at', 'asc')->take(10)->get(); } return $objectList->toJson(); }
public function listAllPatients() { $patients = Patient::orderBy('firstname')->get(); return response()->json($patients); }