select('rules.symptom_id as symptom_id', 'symptoms.name as symptom_name', 'symptoms.code as symptom_code') ->distinct() ->get(); return view('home.index', compact('rules')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $user = Auth::user(); $request->validate([ 'nama' => 'nullable|string', 'email' => 'nullable|string', 'no_telp' => 'nullable|string', 'alamat' => 'nullable|string', ]); $existingUser = User::where('email', $request->email)->where('id', '!=', $user->id)->first(); if ($existingUser) { return redirect()->route('home.index', ['#education'])->with('error', 'Email sudah ada'); } try { if ($request->filled('nama')) { $user->nama = $request->input('nama'); } if ($request->filled('email')) { $user->email = $request->input('email'); } if ($request->filled('no_telp')) { $user->no_telp = $request->input('no_telp'); } if ($request->filled('alamat')) { $user->alamat = $request->input('alamat'); } $user->save(); return redirect()->route('home.index', ['#education'])->with('success', 'User berhasil diupdate'); } catch (\Exception $e) { return redirect()->route('home.index', ['#education'])->with('error', 'Gagal mengupdate user'); } } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }