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