@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index() |
| 19 | 19 | { |
| 20 | - $hospital = Hospital::orderBy('city_id','asc')->paginate(10); |
|
| 20 | + $hospital = Hospital::orderBy('city_id', 'asc')->paginate(10); |
|
| 21 | 21 | $data = [ |
| 22 | 22 | 'role' => session('role'), |
| 23 | 23 | 'hospital' => $hospital |
| 24 | 24 | ]; |
| 25 | - return view('pages.hospital')->with('data',$data); |
|
| 25 | + return view('pages.hospital')->with('data', $data); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | $hospital->public_services = $request->input('public_services'); |
| 64 | 64 | $hospital->cover_images_id = 1; |
| 65 | 65 | |
| 66 | - if($hospital->save()) { |
|
| 67 | - return redirect (route('hospital.index'))->with('success', 'Rumah sakit berhasil di tambahkan !'); |
|
| 66 | + if ($hospital->save()) { |
|
| 67 | + return redirect(route('hospital.index'))->with('success', 'Rumah sakit berhasil di tambahkan !'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return redirect (route('hospital.index'))->with('failed', 'Gagal menambahkan rumah sakit !'); |
|
| 70 | + return redirect(route('hospital.index'))->with('failed', 'Gagal menambahkan rumah sakit !'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function show($id) |
| 80 | 80 | { |
| 81 | 81 | $hospital = Hospital::find($id); |
| 82 | - if(!$hospital) { |
|
| 82 | + if (!$hospital) { |
|
| 83 | 83 | abort(401); |
| 84 | 84 | } |
| 85 | 85 | $data = [ |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | $hospital->public_services = $request->input('public_services'); |
| 137 | 137 | $hospital->cover_images_id = 1; |
| 138 | 138 | |
| 139 | - if($hospital->save()) { |
|
| 140 | - return redirect (route('hospital.index'))->with('success', 'Rumah sakit berhasil di perbaharui'); |
|
| 139 | + if ($hospital->save()) { |
|
| 140 | + return redirect(route('hospital.index'))->with('success', 'Rumah sakit berhasil di perbaharui'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return redirect (route('hospital.edit', $id))->with('failed', 'Gagal memperbaharui rumah sakit !'); |
|
| 143 | + return redirect(route('hospital.edit', $id))->with('failed', 'Gagal memperbaharui rumah sakit !'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | $hospital = Hospital::find($id); |
| 155 | 155 | $delrooms = $this->deleteRoomsAndRoomDetail($id); |
| 156 | 156 | |
| 157 | - if($delrooms){ |
|
| 158 | - if($hospital->delete()) { |
|
| 157 | + if ($delrooms) { |
|
| 158 | + if ($hospital->delete()) { |
|
| 159 | 159 | return redirect(route('hospital.index'))->with('success', 'Rumah sakit dihapus !'); |
| 160 | 160 | } |
| 161 | 161 | return redirect(route('hospital.index'))->with('failed', 'Gagal menghapus rumah sakit !'); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $rooms = $this->getRooms($hospital_id); |
| 173 | 173 | $ids = $rooms->pluck('id')->toArray(); |
| 174 | - if(count($ids) < 1) { |
|
| 174 | + if (count($ids) < 1) { |
|
| 175 | 175 | return true; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | ->where('hospital_id', '=', $hospital_id) |
| 181 | 181 | ->delete(); |
| 182 | 182 | |
| 183 | - if($delroom && $deldetail) { |
|
| 183 | + if ($delroom && $deldetail) { |
|
| 184 | 184 | return true; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $rooms = DB::table('rooms') |
| 197 | 197 | ->selectRaw(DB::raw('rooms.*')) |
| 198 | 198 | ->leftJoin('room_details', 'rooms.id', '=', 'room_details.room_id') |
| 199 | - ->where('room_details.hospital_id','=',$hospital_id) |
|
| 199 | + ->where('room_details.hospital_id', '=', $hospital_id) |
|
| 200 | 200 | ->get(); |
| 201 | 201 | |
| 202 | 202 | return $rooms; |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | public function indexUser() |
| 206 | 206 | { |
| 207 | - $location = City::orderBy('name','asc')->pluck('name', 'id'); |
|
| 207 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 208 | 208 | $img = 'storage/images/hospital-icon.jpg'; |
| 209 | 209 | $data = [ |
| 210 | 210 | 'img' => $img, |
| 211 | 211 | 'location' => $location |
| 212 | 212 | ]; |
| 213 | - return view ('SearchRS')->with('data',$data); |
|
| 213 | + return view('SearchRS')->with('data', $data); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | public function showList() |
@@ -220,30 +220,30 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | public function searchHospital(Request $request) |
| 222 | 222 | { |
| 223 | - if($request->nama == null AND $request->location != null){ |
|
| 224 | - $hospital = Hospital::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 225 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 226 | - $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
| 227 | - }else{ |
|
| 228 | - $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 223 | + if ($request->nama == null AND $request->location != null) { |
|
| 224 | + $hospital = Hospital::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 225 | + }elseif ($request->location == null AND $request->nama != null) { |
|
| 226 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 227 | + } else { |
|
| 228 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 229 | 229 | } |
| 230 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 230 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 231 | 231 | $data = [ |
| 232 | 232 | 'hospital' => $hospital, |
| 233 | 233 | 'location' => $location |
| 234 | 234 | ]; |
| 235 | - return view ('listHospital')->with('data',$data); |
|
| 235 | + return view('listHospital')->with('data', $data); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public function searchContent($content) |
| 239 | 239 | { |
| 240 | - $hospital = Hospital::where('biography','LIKE','%'.$content.'%')->orderBy('name','asc')->paginate(5); |
|
| 241 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 240 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$content.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 241 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 242 | 242 | $data = [ |
| 243 | 243 | 'hospital' => $hospital, |
| 244 | 244 | 'location' => $location |
| 245 | 245 | ]; |
| 246 | - return view ('listHospital')->with('data',$data); |
|
| 246 | + return view('listHospital')->with('data', $data); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | public function viewHospital($id) |
@@ -253,6 +253,6 @@ discard block |
||
| 253 | 253 | 'hospital' => $hospital, |
| 254 | 254 | 'room' => $this->getRooms($id), |
| 255 | 255 | ]; |
| 256 | - return view ('viewhospital')->with('data',$data); |
|
| 256 | + return view('viewhospital')->with('data', $data); |
|
| 257 | 257 | } |
| 258 | 258 | } |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | use App\Hospital; |
| 9 | 9 | use App\City; |
| 10 | 10 | |
| 11 | -class HospitalController extends Controller |
|
| 12 | -{ |
|
| 11 | +class HospitalController extends Controller { |
|
| 13 | 12 | /** |
| 14 | 13 | * Display a listing of the resource. |
| 15 | 14 | * |
@@ -154,7 +153,7 @@ discard block |
||
| 154 | 153 | $hospital = Hospital::find($id); |
| 155 | 154 | $delrooms = $this->deleteRoomsAndRoomDetail($id); |
| 156 | 155 | |
| 157 | - if($delrooms){ |
|
| 156 | + if($delrooms) { |
|
| 158 | 157 | if($hospital->delete()) { |
| 159 | 158 | return redirect(route('hospital.index'))->with('success', 'Rumah sakit dihapus !'); |
| 160 | 159 | } |
@@ -220,11 +219,11 @@ discard block |
||
| 220 | 219 | |
| 221 | 220 | public function searchHospital(Request $request) |
| 222 | 221 | { |
| 223 | - if($request->nama == null AND $request->location != null){ |
|
| 222 | + if($request->nama == null AND $request->location != null) { |
|
| 224 | 223 | $hospital = Hospital::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
| 225 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 224 | + } elseif ($request->location == null AND $request->nama != null) { |
|
| 226 | 225 | $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
| 227 | - }else{ |
|
| 226 | + } else { |
|
| 228 | 227 | $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
| 229 | 228 | } |
| 230 | 229 | $location = City::orderBy('name','asc')->pluck('name','id'); |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | 'updated_at' => Carbon::now() |
| 49 | 49 | )); |
| 50 | 50 | |
| 51 | - if($room_id != null && $hospital_id != null) { |
|
| 51 | + if ($room_id != null && $hospital_id != null) { |
|
| 52 | 52 | $data = [ |
| 53 | 53 | 'hospital_id' => $hospital_id, |
| 54 | 54 | 'room_id' => $room_id |
| 55 | 55 | ]; |
| 56 | 56 | |
| 57 | - if($this->insertRoomDetails($data) && $this->updateHospitalUpdatedAt($hospital_id)) { |
|
| 57 | + if ($this->insertRoomDetails($data) && $this->updateHospitalUpdatedAt($hospital_id)) { |
|
| 58 | 58 | return redirect(route('hospital.show', $hospital_id))->with('success', 'Kamar baru berhasil ditambahkan !'); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $hospital = $this->updateHospitalUpdatedAt($request->input('hospital_id')); |
| 116 | 116 | |
| 117 | - if($room->save() && $hospital == true) { |
|
| 117 | + if ($room->save() && $hospital == true) { |
|
| 118 | 118 | return redirect(route('hospital.show', $request->input('hospital_id')))->with('success', 'Detil Kamar berhasil diubah !'); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | $hospital = $this->updateHospitalUpdatedAt($hospital_id); |
| 133 | 133 | $detail = $this->deleteRoomDetails($room_id, $hospital_id); |
| 134 | 134 | |
| 135 | - if($room && $hospital && $detail) { |
|
| 136 | - return redirect(route('hospital.show', ['id' => $hospital_id]))->with('success', 'Kamar dihapus !'); |
|
| 135 | + if ($room && $hospital && $detail) { |
|
| 136 | + return redirect(route('hospital.show', [ 'id' => $hospital_id ]))->with('success', 'Kamar dihapus !'); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $insert = DB::table('room_details') |
| 147 | 147 | ->insert([ |
| 148 | - 'room_id' => $data['room_id'], |
|
| 149 | - 'hospital_id' => $data['hospital_id'] |
|
| 148 | + 'room_id' => $data[ 'room_id' ], |
|
| 149 | + 'hospital_id' => $data[ 'hospital_id' ] |
|
| 150 | 150 | ]); |
| 151 | 151 | |
| 152 | - if($insert) { |
|
| 152 | + if ($insert) { |
|
| 153 | 153 | return true; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ->where('hospital_id', '=', $hospital_id) |
| 169 | 169 | ->delete(); |
| 170 | 170 | |
| 171 | - if($delete) { |
|
| 171 | + if ($delete) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $hospital = Hospital::find($id); |
| 185 | 185 | $hospital->updated_at = Carbon::now(); |
| 186 | - if($hospital->save()) { |
|
| 186 | + if ($hospital->save()) { |
|
| 187 | 187 | return true; |
| 188 | 188 | } |
| 189 | 189 | |