@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function index() |
22 | 22 | { |
23 | 23 | $doctors = Doctor::orderBy('created_at', 'desc')->paginate(10); |
24 | - if(!$doctors) { |
|
24 | + if (!$doctors) { |
|
25 | 25 | abort(503); |
26 | 26 | } |
27 | 27 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function store(Request $request) |
54 | 54 | { |
55 | - $this->validate($request,[ |
|
55 | + $this->validate($request, [ |
|
56 | 56 | 'specialty' => 'required', |
57 | 57 | 'name' => 'required|min:3|max:50', |
58 | 58 | 'license' => 'required|min:3|max:191', |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | $doctor->email = $request->input('email'); |
70 | 70 | $doctor->password = Hash::make($request->password); |
71 | 71 | |
72 | - if($doctor->save()) { |
|
73 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
72 | + if ($doctor->save()) { |
|
73 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
74 | 74 | } |
75 | 75 | |
76 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
76 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,20 +84,20 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function show($id) |
86 | 86 | { |
87 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
88 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
87 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
88 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
89 | 89 | $data = [ |
90 | 90 | 'doctor' => $doctor, |
91 | 91 | 'location' => $location |
92 | 92 | ]; |
93 | - return view('listDoctor')->with('data',$data); |
|
93 | + return view('listDoctor')->with('data', $data); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function showDoctor($id) |
97 | 97 | { |
98 | 98 | $doctor = Doctor::find($id); |
99 | 99 | |
100 | - return view('viewDoctor')->with('doctor',$doctor); |
|
100 | + return view('viewDoctor')->with('doctor', $doctor); |
|
101 | 101 | } |
102 | 102 | /** |
103 | 103 | * Show the form for editing the specified resource. |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function update(Request $request, $id) |
127 | 127 | { |
128 | - $this->validate($request,[ |
|
128 | + $this->validate($request, [ |
|
129 | 129 | 'name' => 'required|min:3|max:50', |
130 | 130 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
131 | 131 | 'password_confirmation' => 'min:6' |
@@ -135,41 +135,41 @@ discard block |
||
135 | 135 | $doctor = Doctor::find($id); |
136 | 136 | $doctor->name = $request->input('name'); |
137 | 137 | $doctor->password = $pass; |
138 | - if($doctor->save()) { |
|
139 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
138 | + if ($doctor->save()) { |
|
139 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
140 | 140 | } |
141 | 141 | |
142 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
142 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | public function searchDoctor(Request $request) |
146 | 146 | { |
147 | - if($request->nama == null AND $request->location != null){ |
|
148 | - $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
149 | - }elseif ($request->location == null AND $request->nama != null){ |
|
150 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
151 | - }else{ |
|
152 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
147 | + if ($request->nama == null AND $request->location != null) { |
|
148 | + $doctor = Doctor::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
149 | + }elseif ($request->location == null AND $request->nama != null) { |
|
150 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
151 | + } else { |
|
152 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
153 | 153 | } |
154 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
154 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
155 | 155 | $data = [ |
156 | 156 | 'doctor' => $doctor, |
157 | 157 | 'location' => $location |
158 | 158 | ]; |
159 | 159 | |
160 | - return view('listDoctor')->with('data',$data); |
|
160 | + return view('listDoctor')->with('data', $data); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function searchByRadio(Request $request) |
164 | 164 | { |
165 | - $locationId = City::where('name','LIKE','%'.$request->location.'%')->pluck('id','name'); |
|
166 | - $doctor = Doctor::where('city_id',$locationId)->orderBy('name','asc')->paginate(5); |
|
167 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
165 | + $locationId = City::where('name', 'LIKE', '%'.$request->location.'%')->pluck('id', 'name'); |
|
166 | + $doctor = Doctor::where('city_id', $locationId)->orderBy('name', 'asc')->paginate(5); |
|
167 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
168 | 168 | $data = [ |
169 | 169 | 'doctor'=>$doctor, |
170 | 170 | 'location' => $location |
171 | 171 | ]; |
172 | - return view('listDoctor')->with('data',$data); |
|
172 | + return view('listDoctor')->with('data', $data); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $doctor = Doctor::find($id); |
184 | 184 | $doctor->delete(); |
185 | 185 | |
186 | - return redirect (route('doctor.index')); |
|
186 | + return redirect(route('doctor.index')); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | } |