public function saveObject(Request $request) { if (isset($request->id) && !empty($request->id)) { $object = Patient::whereRaw('patient_no = ? or id = ?', array($request->id, $request->id))->first(); } else { $object = new Patient(); } $object->patient_no = $request->patient_no; $object->lastname = $request->lastname; $object->firstname = $request->firstname; $object->address = $request->address; $object->contact = $request->contact; $object->email = $request->email; $object->gender = $request->gender; $object->birthday = $request->birthday; $object->bloodtype = $request->bloodtype; $object->occupancy = $request->occupancy; $object->status = $request->status; $object->contact_person = $request->contact_person; $object->save(); return 200; }