@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function index() |
20 | 20 | { |
21 | - $doctor = Doctor::orderBy('name','asc')->paginate(10); |
|
21 | + $doctor = Doctor::orderBy('name', 'asc')->paginate(10); |
|
22 | 22 | $data = [ |
23 | 23 | 'role' => session('role'), |
24 | 24 | 'doctor' => $doctor, |
25 | 25 | ]; |
26 | - return view('pages.doctor')->with('data',$data); |
|
26 | + return view('pages.doctor')->with('data', $data); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function store(Request $request) |
48 | 48 | { |
49 | - $this->validate($request,[ |
|
49 | + $this->validate($request, [ |
|
50 | 50 | 'specialty' => 'required', |
51 | 51 | 'name' => 'required|min:3|max:50', |
52 | 52 | 'license' => 'required|min:3|max:191', |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | $doctor->email = $request->input('email'); |
64 | 64 | $doctor->password = Hash::make($request->password); |
65 | 65 | |
66 | - if($doctor->save()) { |
|
67 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
66 | + if ($doctor->save()) { |
|
67 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
68 | 68 | } |
69 | 69 | |
70 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
70 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function show($id) |
80 | 80 | { |
81 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
82 | - $location = City::pluck('name','id'); |
|
81 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
82 | + $location = City::pluck('name', 'id'); |
|
83 | 83 | $data = [ |
84 | 84 | 'doctor' => $doctor, |
85 | 85 | 'location' => $location |
86 | 86 | ]; |
87 | - return view('listDoctor')->with('data',$data); |
|
87 | + return view('listDoctor')->with('data', $data); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | public function showDoctor($id) |
91 | 91 | { |
92 | 92 | $doctor = Doctor::find($id); |
93 | 93 | |
94 | - return view('viewDoctor')->with('doctor',$doctor); |
|
94 | + return view('viewDoctor')->with('doctor', $doctor); |
|
95 | 95 | } |
96 | 96 | /** |
97 | 97 | * Show the form for editing the specified resource. |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function update(Request $request, $id) |
121 | 121 | { |
122 | - $this->validate($request,[ |
|
122 | + $this->validate($request, [ |
|
123 | 123 | 'name' => 'required|min:3|max:50', |
124 | 124 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
125 | 125 | 'password_confirmation' => 'min:6' |
@@ -129,29 +129,29 @@ discard block |
||
129 | 129 | $doctor = Doctor::find($id); |
130 | 130 | $doctor->name = $request->input('name'); |
131 | 131 | $doctor->password = $pass; |
132 | - if($doctor->save()) { |
|
133 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
132 | + if ($doctor->save()) { |
|
133 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
134 | 134 | } |
135 | 135 | |
136 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
136 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public function searchDoctor(Request $request) |
140 | 140 | { |
141 | - if ($request->nama == null AND $request->location != null){ |
|
142 | - $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
143 | - }elseif ($request->location == null AND $request->nama != null){ |
|
144 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
145 | - }else{ |
|
146 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
141 | + if ($request->nama == null AND $request->location != null) { |
|
142 | + $doctor = Doctor::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
143 | + }elseif ($request->location == null AND $request->nama != null) { |
|
144 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
145 | + } else { |
|
146 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
147 | 147 | } |
148 | - $location = City::pluck('name','id'); |
|
148 | + $location = City::pluck('name', 'id'); |
|
149 | 149 | $data = [ |
150 | 150 | 'doctor' => $doctor, |
151 | 151 | 'location' => $location |
152 | 152 | ]; |
153 | 153 | |
154 | - return view('listDoctor')->with('data',$data); |
|
154 | + return view('listDoctor')->with('data', $data); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $doctor = Doctor::find($id); |
172 | 172 | $doctor->delete(); |
173 | 173 | |
174 | - return redirect (route('doctor.index')); |
|
174 | + return redirect(route('doctor.index')); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | use Illuminate\Support\Facades\Hash; |
10 | 10 | |
11 | 11 | |
12 | -class DoctorController extends Controller |
|
13 | -{ |
|
12 | +class DoctorController extends Controller { |
|
14 | 13 | /** |
15 | 14 | * Display a listing of the resource. |
16 | 15 | * |
@@ -138,11 +137,11 @@ discard block |
||
138 | 137 | |
139 | 138 | public function searchDoctor(Request $request) |
140 | 139 | { |
141 | - if ($request->nama == null AND $request->location != null){ |
|
140 | + if ($request->nama == null AND $request->location != null) { |
|
142 | 141 | $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
143 | - }elseif ($request->location == null AND $request->nama != null){ |
|
142 | + } elseif ($request->location == null AND $request->nama != null) { |
|
144 | 143 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
145 | - }else{ |
|
144 | + } else { |
|
146 | 145 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
147 | 146 | } |
148 | 147 | $location = City::pluck('name','id'); |