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