name = $request->name; // // $customers->email = $request->email; // // $customers->password = $request->password; // // $customers->gender = $request->gender; // // if($request->is_active){ // // $employee->is_active = 1; // // } // // $employee->date_of_birth = $request->date_of_birth; // // $employee->roll = $request->roll; // if($employee->save()) // { // return redirect()->back()->with(['msg' => 1]); // } // else // { // return redirect()->back()->with(['msg' => 2]); // } // return view('update.customer',compact('customers')); // } // public function edit($id){ // $customers = Customer::find($id); // return view('edit.customer', compact('customers')); // } // } { public function index() { $patient = new Patient(); $patient = $patient->get(); return view('patient.index',[ 'patient' =>$patient ]); } public function edit($id) { $patients = Patient::where('id_patient' ,'=',$id)->get(); return view('patient.edit_patient',compact('patients')); } public function create() { return view('patient.create'); } public function store(Request $request) { $patient = new Patient(); $patient->id_patient = $request->id_patient; $patient->patient_name = $request->patient_name; $patient->medical_record_number = $request->medical_record_number; $patient->phone_number = $request->phone_number; $patient->gender = $request->gender; $patient->birth_date = $request->birth_date; $patient->address = $request->address; $patient->active = $request->active; $patient->save(); return Redirect()->route('add.patient'); return redirect()->route('patient.index')->with('success', 'Data berhasil tambahkan.'); } public function update($id,Request $request) { $patient = Patient::find($id); $patient->id_patient = $request->id_patient; $patient->patient_name = $request->patient_name; $patient->medical_record_number = $request->medical_record_number; $patient->phone_number = $request->phone_number; $patient->gender = $request->gender; $patient->birth_date = $request->birth_date; $patient->address = $request->address; if($request->is_active){ $patient->is_active = 1; } if($patient->save()) { return redirect()->back()->with(['msg' => 1]); } else { return redirect()->back()->with(['msg' => 2]); } return view('patient.edit',compact('patients')); return redirect()->route('patient.index')->with('success', 'Data berhasil diperbarui.'); } public function patientsData(){ $patients = Patient::all(); return view('Admin.all_patients',compact('patients')); } public function delete($id_patient) { $patient = Patient::find($id); $patient->delete(); } public function show() { $patient = Patient::findOrFail($id_patient); return view('patient.show', compact('patients')); } }