@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct() |
| 13 | 13 | { |
| 14 | - $this->middleware('auth', ['except' => [ |
|
| 14 | + $this->middleware('auth', [ 'except' => [ |
|
| 15 | 15 | 'index', 'show' |
| 16 | - ]]); |
|
| 16 | + ] ]); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $topic = $this->addTopic($request->input('topic')); |
| 63 | 63 | |
| 64 | - if($topic != null) { |
|
| 64 | + if ($topic != null) { |
|
| 65 | 65 | $thread = new Thread; |
| 66 | 66 | $thread->user_id = $this->currentUser()->id; |
| 67 | 67 | $thread->id_topic = $topic->id; |
| 68 | 68 | $thread->question = $request->input('question'); |
| 69 | 69 | |
| 70 | - if($thread->save()) { |
|
| 70 | + if ($thread->save()) { |
|
| 71 | 71 | return redirect(route('user.thread.index'))->with('success', 'Pertanyaan dikirim !'); |
| 72 | 72 | } |
| 73 | 73 | return redirect()->back()->with('failed', 'Gagal mengirim pertanyaan, silahkan coba lagi nanti.'); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function show($id) |
| 85 | 85 | { |
| 86 | 86 | $thread = Thread::find($id); |
| 87 | - if(!$thread) { |
|
| 87 | + if (!$thread) { |
|
| 88 | 88 | abort(404); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $user = $this->currentUser(); |
| 108 | 108 | $thread = Thread::find($id); |
| 109 | - if($thread->user_id != $user->id) { |
|
| 109 | + if ($thread->user_id != $user->id) { |
|
| 110 | 110 | return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.'); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if($thread->doctor_id != null) { |
|
| 113 | + if ($thread->doctor_id != null) { |
|
| 114 | 114 | return redirect()->back()->with('warning', 'Tidak dapat mengubah pertanyaan karena sudah terjawab, silahkan tanyakan pertanyaan baru.'); |
| 115 | 115 | } |
| 116 | 116 | $threads = Thread::orderBy('created_at', 'desc')->paginate(5); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $user = $this->currentUser(); |
| 137 | 137 | $thread = Thread::find($id); |
| 138 | - if($thread->user_id != $user->id) { |
|
| 138 | + if ($thread->user_id != $user->id) { |
|
| 139 | 139 | return redirect()->back()->with('warning', 'Anda tidak berhak mengubah ulasan tersebut.'); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $thread->topic = $request->input('topic'); |
| 148 | 148 | $thread->question = $request->input('question'); |
| 149 | - if($thread->save()) { |
|
| 149 | + if ($thread->save()) { |
|
| 150 | 150 | return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !'); |
| 151 | 151 | } |
| 152 | 152 | return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !'); |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $user = $this->currentUser(); |
| 164 | 164 | $thread = Thread::find($id); |
| 165 | - if($thread->user_id != $user->id) { |
|
| 165 | + if ($thread->user_id != $user->id) { |
|
| 166 | 166 | return redirect()->back()->with('warning', 'Anda tidak berhak menghapus ulasan tersebut.'); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 169 | + if ($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 170 | 170 | return redirect(route('user.profile'))->with('success', 'Ulasan dihapus !'); |
| 171 | 171 | } |
| 172 | 172 | return redirect()->back()->with('failed', 'Gagal menghapus ulasan.'); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $new = new ThreadTopic; |
| 192 | 192 | $new->topic_name = $topic; |
| 193 | - if($new->save()) { |
|
| 193 | + if ($new->save()) { |
|
| 194 | 194 | return $new; |
| 195 | 195 | } |
| 196 | 196 | return null; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | private function deleteTopic($id) |
| 206 | 206 | { |
| 207 | 207 | $topic = ThreadTopic::find($id); |
| 208 | - if($topic->delete()) { |
|
| 208 | + if ($topic->delete()) { |
|
| 209 | 209 | return true; |
| 210 | 210 | } |
| 211 | 211 | return false; |
@@ -10,9 +10,9 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct() |
| 12 | 12 | { |
| 13 | - $this->middleware('auth:admin', ['except' => [ |
|
| 13 | + $this->middleware('auth:admin', [ 'except' => [ |
|
| 14 | 14 | 'index', 'show' |
| 15 | - ]]); |
|
| 15 | + ] ]); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $threads = null; |
| 27 | 27 | $count = null; |
| 28 | - if($query == "all") { |
|
| 28 | + if ($query == "all") { |
|
| 29 | 29 | $threads = Thread::orderBy('created_at', 'desc')->paginate(15); |
| 30 | - } elseif($query == "answered") { |
|
| 30 | + } elseif ($query == "answered") { |
|
| 31 | 31 | $threads = Thread::where('status', true) |
| 32 | 32 | ->orderBy('created_at', 'desc') |
| 33 | 33 | ->paginate(15); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function show($id) |
| 61 | 61 | { |
| 62 | 62 | $thread = Thread::find($id); |
| 63 | - if(!$thread) { |
|
| 63 | + if (!$thread) { |
|
| 64 | 64 | abort(404); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | public function destroy($id) |
| 83 | 83 | { |
| 84 | 84 | $thread = Thread::find($id); |
| 85 | - if($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 86 | - return redirect(route('admin.thread.index', ['query' => "all"]))->with('success', 'Diskusi dihapus !'); |
|
| 85 | + if ($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 86 | + return redirect(route('admin.thread.index', [ 'query' => "all" ]))->with('success', 'Diskusi dihapus !'); |
|
| 87 | 87 | } |
| 88 | 88 | return redirect()->back()->with('failed', 'Gagal menghapus diskusi.'); |
| 89 | 89 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | public function deleteTopic($id) |
| 99 | 99 | { |
| 100 | 100 | $topic = ThreadTopic::find($id); |
| 101 | - if($topic->delete()) { |
|
| 101 | + if ($topic->delete()) { |
|
| 102 | 102 | return true; |
| 103 | 103 | } |
| 104 | 104 | return false; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function index($id) |
| 22 | 22 | { |
| 23 | 23 | $doctor = $this->currentUser(); |
| 24 | - if($doctor->id != $id) { |
|
| 24 | + if ($doctor->id != $id) { |
|
| 25 | 25 | return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $thread->answer = $request->input('answer'); |
| 54 | 54 | $thread->status = true; |
| 55 | 55 | |
| 56 | - if($thread->save()) { |
|
| 56 | + if ($thread->save()) { |
|
| 57 | 57 | return redirect(route('doctor.thread.show', $id))->with('success', 'Jawaban terkirim !'); |
| 58 | 58 | } |
| 59 | 59 | return redirect()->back()->with('failed', 'Gagal mengirim jawaban.'); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function edit($id) |
| 69 | 69 | { |
| 70 | 70 | $thread = Thread::find($id); |
| 71 | - if(!$thread) { |
|
| 71 | + if (!$thread) { |
|
| 72 | 72 | abort(404); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $thread->answer = $request->input('answer'); |
| 100 | 100 | $thread->status = true; |
| 101 | 101 | |
| 102 | - if($thread->save()) { |
|
| 102 | + if ($thread->save()) { |
|
| 103 | 103 | return redirect(route('doctor.thread.show', $id))->with('success', 'Perubahan jawaban terkirim !'); |
| 104 | 104 | } |
| 105 | 105 | return redirect()->back()->with('failed', 'Gagal mengirim perubahan jawaban.'); |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | public function destroy($id) |
| 115 | 115 | { |
| 116 | 116 | $thread = Thread::find($id); |
| 117 | - if($thread->doctor_id != $this->currentUser()->id) { |
|
| 117 | + if ($thread->doctor_id != $this->currentUser()->id) { |
|
| 118 | 118 | return redirect()->back()->with('warning', 'Anda tidak berhak menghapus jawaban untuk diskusi tersebut.'); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $thread->doctor_id = null; |
| 122 | 122 | $thread->answer = null; |
| 123 | 123 | $thread->status = false; |
| 124 | - if($thread->save()) { |
|
| 124 | + if ($thread->save()) { |
|
| 125 | 125 | return redirect()->back()->with('success', 'Jawaban dihapus !'); |
| 126 | 126 | } |
| 127 | 127 | return redirect()->back()->with('failed', 'Gagal mengahapus jawaban.'); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | // abort(503); |
| 24 | 24 | $doctors = Doctor::orderBy('created_at', 'desc')->paginate(10); |
| 25 | - if(!$doctors) { |
|
| 25 | + if (!$doctors) { |
|
| 26 | 26 | abort(503); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function store(Request $request) |
| 55 | 55 | { |
| 56 | - $this->validate($request,[ |
|
| 56 | + $this->validate($request, [ |
|
| 57 | 57 | 'specialty' => 'required', |
| 58 | 58 | 'name' => 'required|min:3|max:50', |
| 59 | 59 | 'license' => 'required|min:3|max:191', |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | $doctor->email = $request->input('email'); |
| 71 | 71 | $doctor->password = Hash::make($request->password); |
| 72 | 72 | |
| 73 | - if($doctor->save()) { |
|
| 74 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 73 | + if ($doctor->save()) { |
|
| 74 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 77 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function show($id) |
| 87 | 87 | { |
| 88 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
| 89 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 88 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
| 89 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 90 | 90 | $data = [ |
| 91 | 91 | 'doctor' => $doctor, |
| 92 | 92 | 'location' => $location |
| 93 | 93 | ]; |
| 94 | - return view('listDoctor')->with('data',$data); |
|
| 94 | + return view('listDoctor')->with('data', $data); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function showDoctor($id) |
| 98 | 98 | { |
| 99 | 99 | $doctor = Doctor::find($id); |
| 100 | 100 | |
| 101 | - return view('viewDoctor')->with('doctor',$doctor); |
|
| 101 | + return view('viewDoctor')->with('doctor', $doctor); |
|
| 102 | 102 | } |
| 103 | 103 | /** |
| 104 | 104 | * Show the form for editing the specified resource. |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function update(Request $request, $id) |
| 128 | 128 | { |
| 129 | - $this->validate($request,[ |
|
| 129 | + $this->validate($request, [ |
|
| 130 | 130 | 'name' => 'required|min:3|max:50', |
| 131 | 131 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
| 132 | 132 | 'password_confirmation' => 'min:6' |
@@ -136,41 +136,41 @@ discard block |
||
| 136 | 136 | $doctor = Doctor::find($id); |
| 137 | 137 | $doctor->name = $request->input('name'); |
| 138 | 138 | $doctor->password = $pass; |
| 139 | - if($doctor->save()) { |
|
| 140 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 139 | + if ($doctor->save()) { |
|
| 140 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 143 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | public function searchDoctor(Request $request) |
| 147 | 147 | { |
| 148 | - if($request->nama == null AND $request->location != null){ |
|
| 149 | - $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 150 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 151 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
| 152 | - }else{ |
|
| 153 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 148 | + if ($request->nama == null AND $request->location != null) { |
|
| 149 | + $doctor = Doctor::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 150 | + }elseif ($request->location == null AND $request->nama != null) { |
|
| 151 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 152 | + } else { |
|
| 153 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 154 | 154 | } |
| 155 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 155 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 156 | 156 | $data = [ |
| 157 | 157 | 'doctor' => $doctor, |
| 158 | 158 | 'location' => $location |
| 159 | 159 | ]; |
| 160 | 160 | |
| 161 | - return view('listDoctor')->with('data',$data); |
|
| 161 | + return view('listDoctor')->with('data', $data); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function searchByRadio(Request $request) |
| 165 | 165 | { |
| 166 | - $locationId = City::where('name','LIKE','%'.$request->location.'%')->pluck('id','name'); |
|
| 167 | - $doctor = Doctor::where('city_id',$locationId)->orderBy('name','asc')->paginate(5); |
|
| 168 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 166 | + $locationId = City::where('name', 'LIKE', '%'.$request->location.'%')->pluck('id', 'name'); |
|
| 167 | + $doctor = Doctor::where('city_id', $locationId)->orderBy('name', 'asc')->paginate(5); |
|
| 168 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 169 | 169 | $data = [ |
| 170 | 170 | 'doctor'=>$doctor, |
| 171 | 171 | 'location' => $location |
| 172 | 172 | ]; |
| 173 | - return view('listDoctor')->with('data',$data); |
|
| 173 | + return view('listDoctor')->with('data', $data); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $doctor = Doctor::find($id); |
| 185 | 185 | $doctor->delete(); |
| 186 | 186 | |
| 187 | - return redirect (route('doctor.index')); |
|
| 187 | + return redirect(route('doctor.index')); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |