@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | use Illuminate\Contracts\Auth\MustVerifyEmail; |
| 10 | 10 | use Illuminate\Foundation\Auth\User as Authenticatable; |
| 11 | 11 | |
| 12 | -class Doctor extends Authenticatable |
|
| 13 | -{ |
|
| 12 | +class Doctor extends Authenticatable { |
|
| 14 | 13 | use Notifiable; |
| 15 | 14 | |
| 16 | 15 | protected $guard = 'doctor'; |
@@ -74,7 +73,8 @@ discard block |
||
| 74 | 73 | return $this->belongsTo('App\DoctorSpecialization', 'id'); |
| 75 | 74 | } |
| 76 | 75 | |
| 77 | - public function city() { |
|
| 76 | + public function city() |
|
| 77 | + { |
|
| 78 | 78 | return $this->belongsTo('App\City', 'city_id'); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class City extends Model |
|
| 8 | -{ |
|
| 7 | +class City extends Model { |
|
| 9 | 8 | /** |
| 10 | 9 | * @var string |
| 11 | 10 | */ |
@@ -37,7 +36,8 @@ discard block |
||
| 37 | 36 | return $this->hasMany('App\Hospital'); |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | - public function doctor() { |
|
| 39 | + public function doctor() |
|
| 40 | + { |
|
| 41 | 41 | return $this->hasOne('App\Doctor', 'city_id'); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class DoctorSpecialization extends Model |
|
| 8 | -{ |
|
| 7 | +class DoctorSpecialization extends Model { |
|
| 9 | 8 | /** |
| 10 | 9 | * @var string |
| 11 | 10 | */ |
@@ -29,7 +28,8 @@ discard block |
||
| 29 | 28 | 'updated_at' |
| 30 | 29 | ]; |
| 31 | 30 | |
| 32 | - public function doctor() { |
|
| 31 | + public function doctor() |
|
| 32 | + { |
|
| 33 | 33 | return $this->hasOne('App\Doctor', 'specialization_id'); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function index() |
| 16 | 16 | { |
| 17 | - $articles = Articles::orderBy('category','asc')->paginate(5); |
|
| 17 | + $articles = Articles::orderBy('category', 'asc')->paginate(5); |
|
| 18 | 18 | $data = [ |
| 19 | 19 | 'articles' => $articles |
| 20 | 20 | ]; |
@@ -37,20 +37,20 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function store(Request $request) |
| 39 | 39 | { |
| 40 | - $this->validate($request,[ |
|
| 40 | + $this->validate($request, [ |
|
| 41 | 41 | 'category' => 'required', |
| 42 | 42 | 'title' => 'required', |
| 43 | 43 | 'content' => 'required|min:500', |
| 44 | 44 | 'cover_image' => 'image|nullable|max:3999' |
| 45 | 45 | ]); |
| 46 | 46 | |
| 47 | - if($request->hasFile('cover_image')){ |
|
| 47 | + if ($request->hasFile('cover_image')) { |
|
| 48 | 48 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 49 | 49 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 50 | 50 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 51 | 51 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 52 | 52 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 53 | - }else { |
|
| 53 | + } else { |
|
| 54 | 54 | $fileNameToStore = 'noimage.jpg'; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,15 +58,15 @@ discard block |
||
| 58 | 58 | $article->category = $request->input('category'); |
| 59 | 59 | $article->title = $request->input('title'); |
| 60 | 60 | $article->content = $request->input('content'); |
| 61 | - if(session('guard') == 'admin') { |
|
| 61 | + if (session('guard') == 'admin') { |
|
| 62 | 62 | $article->admin_id = Auth::guard('admin')->user()->id; |
| 63 | 63 | } else { |
| 64 | 64 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
| 65 | 65 | } |
| 66 | 66 | $article->cover_image = $fileNameToStore; |
| 67 | 67 | |
| 68 | - if($article->save()) { |
|
| 69 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 68 | + if ($article->save()) { |
|
| 69 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return redirect(route(session('guard').'.article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function show($id) |
| 80 | 80 | { |
| 81 | 81 | $article = Articles::find($id); |
| 82 | - if(!$article) { |
|
| 82 | + if (!$article) { |
|
| 83 | 83 | abort(404); |
| 84 | 84 | } |
| 85 | 85 | return view('pages.ext.view-article')->with('article', $article); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $data = [ |
| 115 | - 'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(), |
|
| 115 | + 'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(), |
|
| 116 | 116 | 'category' => $category, |
| 117 | 117 | 'cat' => $cat |
| 118 | 118 | ]; |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | $data = [ |
| 145 | 145 | 'articles' => Articles::where('category', $cat) |
| 146 | - ->where('title','LIKE',$name.'%') |
|
| 147 | - ->orderBy('title','asc') |
|
| 146 | + ->where('title', 'LIKE', $name.'%') |
|
| 147 | + ->orderBy('title', 'asc') |
|
| 148 | 148 | ->get(), |
| 149 | 149 | 'category' => $category, |
| 150 | 150 | 'cat' => $cat |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $cari = $request->cari; |
| 159 | 159 | $articles = Articles::where('category', $cat) |
| 160 | - ->where('content','LIKE','%'.$cari.'%') |
|
| 161 | - ->orderBy('title','asc') |
|
| 160 | + ->where('content', 'LIKE', '%'.$cari.'%') |
|
| 161 | + ->orderBy('title', 'asc') |
|
| 162 | 162 | ->get(); |
| 163 | 163 | $category = null; |
| 164 | 164 | switch ($cat) { |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | public function edit($id) |
| 195 | 195 | { |
| 196 | 196 | $article = Articles::find($id); |
| 197 | - if(!$article) { |
|
| 197 | + if (!$article) { |
|
| 198 | 198 | abort(404); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if($article->writer()['data']->id != Auth::guard(session('guard'))->user()->id) { |
|
| 201 | + if ($article->writer()[ 'data' ]->id != Auth::guard(session('guard'))->user()->id) { |
|
| 202 | 202 | return redirect(session('guard').'/article')->with('warning', 'Anda tidak berhak untuk mengubah Artikel tersebut.'); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function update(Request $request, $id) |
| 218 | 218 | { |
| 219 | - $this->validate($request,[ |
|
| 219 | + $this->validate($request, [ |
|
| 220 | 220 | 'category' => 'required', |
| 221 | 221 | 'title' => 'required', |
| 222 | 222 | 'content' => 'required|min:500', |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | ]); |
| 226 | 226 | |
| 227 | - if($request->hasFile('cover_image')){ |
|
| 227 | + if ($request->hasFile('cover_image')) { |
|
| 228 | 228 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 229 | 229 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 230 | 230 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | $article->category = $request->input('category'); |
| 237 | 237 | $article->title = $request->input('title'); |
| 238 | 238 | $article->content = $request->input('content'); |
| 239 | - if($request->hasFile('cover_image')){ |
|
| 239 | + if ($request->hasFile('cover_image')) { |
|
| 240 | 240 | $article->cover_image = $fileNameToStore; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - if($article->save()) { |
|
| 244 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 243 | + if ($article->save()) { |
|
| 244 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - return redirect (route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 247 | + return redirect(route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | $article = Articles::find($id); |
| 257 | 257 | |
| 258 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 258 | + if ($article->cover_image != 'noimage.jpg') { |
|
| 259 | 259 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if($article->delete()) { |
|
| 262 | + if ($article->delete()) { |
|
| 263 | 263 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | use Illuminate\Support\Facades\Auth; |
| 8 | 8 | use App\Articles; |
| 9 | 9 | |
| 10 | -class ArticleController extends Controller |
|
| 11 | -{ |
|
| 10 | +class ArticleController extends Controller { |
|
| 12 | 11 | /** |
| 13 | 12 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
| 14 | 13 | */ |
@@ -44,13 +43,13 @@ discard block |
||
| 44 | 43 | 'cover_image' => 'image|nullable|max:3999' |
| 45 | 44 | ]); |
| 46 | 45 | |
| 47 | - if($request->hasFile('cover_image')){ |
|
| 46 | + if($request->hasFile('cover_image')) { |
|
| 48 | 47 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 49 | 48 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 50 | 49 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 51 | 50 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 52 | 51 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 53 | - }else { |
|
| 52 | + } else { |
|
| 54 | 53 | $fileNameToStore = 'noimage.jpg'; |
| 55 | 54 | } |
| 56 | 55 | |
@@ -224,7 +223,7 @@ discard block |
||
| 224 | 223 | |
| 225 | 224 | ]); |
| 226 | 225 | |
| 227 | - if($request->hasFile('cover_image')){ |
|
| 226 | + if($request->hasFile('cover_image')) { |
|
| 228 | 227 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 229 | 228 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 230 | 229 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -236,7 +235,7 @@ discard block |
||
| 236 | 235 | $article->category = $request->input('category'); |
| 237 | 236 | $article->title = $request->input('title'); |
| 238 | 237 | $article->content = $request->input('content'); |
| 239 | - if($request->hasFile('cover_image')){ |
|
| 238 | + if($request->hasFile('cover_image')) { |
|
| 240 | 239 | $article->cover_image = $fileNameToStore; |
| 241 | 240 | } |
| 242 | 241 | |
@@ -255,7 +254,7 @@ discard block |
||
| 255 | 254 | { |
| 256 | 255 | $article = Articles::find($id); |
| 257 | 256 | |
| 258 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 257 | + if($article->cover_image != 'noimage.jpg') { |
|
| 259 | 258 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 260 | 259 | } |
| 261 | 260 | |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace App\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | -Use Illuminate\Support\Facades\Storage; |
|
| 6 | +use Illuminate\Support\Facades\Storage; |
|
| 7 | 7 | use Illuminate\Support\Facades\Auth; |
| 8 | 8 | use App\Articles; |
| 9 | 9 | |
@@ -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,7 +154,7 @@ discard block |
||
| 154 | 154 | $hospital = Hospital::find($id); |
| 155 | 155 | $rooms = $this->deleteRoomsAndRoomDetail($id); |
| 156 | 156 | |
| 157 | - if($hospital->delete() && $rooms) { |
|
| 157 | + if ($hospital->delete() && $rooms) { |
|
| 158 | 158 | return redirect(route('hospital.index')); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | ->where('hospital_id', '=', $hospital_id) |
| 175 | 175 | ->delete(); |
| 176 | 176 | |
| 177 | - if($delroom && $deldetail) { |
|
| 177 | + if ($delroom && $deldetail) { |
|
| 178 | 178 | return true; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $rooms = DB::table('rooms') |
| 191 | 191 | ->selectRaw(DB::raw('rooms.*')) |
| 192 | 192 | ->leftJoin('room_details', 'rooms.id', '=', 'room_details.room_id') |
| 193 | - ->where('room_details.hospital_id','=',$hospital_id) |
|
| 193 | + ->where('room_details.hospital_id', '=', $hospital_id) |
|
| 194 | 194 | ->get(); |
| 195 | 195 | |
| 196 | 196 | return $rooms; |
@@ -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,29 +137,29 @@ 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 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $doctor = Doctor::find($id); |
| 174 | 174 | $doctor->delete(); |
| 175 | 175 | |
| 176 | - return redirect (route('doctor.index')); |
|
| 176 | + return redirect(route('doctor.index')); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | use Psy\Exception\ErrorException; |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -class DoctorController extends Controller |
|
| 15 | -{ |
|
| 14 | +class DoctorController extends Controller { |
|
| 16 | 15 | /** |
| 17 | 16 | * Returning view with data resource |
| 18 | 17 | * |
@@ -146,11 +145,11 @@ discard block |
||
| 146 | 145 | |
| 147 | 146 | public function searchDoctor(Request $request) |
| 148 | 147 | { |
| 149 | - if($request->nama == null AND $request->location != null){ |
|
| 148 | + if($request->nama == null AND $request->location != null) { |
|
| 150 | 149 | $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
| 151 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 150 | + } elseif ($request->location == null AND $request->nama != null) { |
|
| 152 | 151 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
| 153 | - }else{ |
|
| 152 | + } else { |
|
| 154 | 153 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
| 155 | 154 | } |
| 156 | 155 | $location = City::orderBy('name','asc')->pluck('name','id'); |