Passed
Push — master ( 14ba86...1ea504 )
by Faiq
04:32
created
app/Http/Controllers/ThreadAnswerController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function index($id)
23 23
     {
24 24
         $doctor = $this->currentUser();
25
-        if($doctor->id != $id) {
25
+        if ($doctor->id != $id) {
26 26
             return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.');
27 27
         }
28 28
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $thread->answer = $request->input('answer');
55 55
         $thread->status = true;
56 56
 
57
-        if($thread->save()) {
57
+        if ($thread->save()) {
58 58
 
59 59
             $log = Common::registerLog([
60 60
                 'action' => "menjawab diskusi oleh ",
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     public function edit($id)
80 80
     {
81 81
         $thread = Thread::find($id);
82
-        if(!$thread) {
82
+        if (!$thread) {
83 83
             abort(404);
84 84
         }
85 85
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $thread->answer = $request->input('answer');
111 111
         $thread->status = true;
112 112
 
113
-        if($thread->save()) {
113
+        if ($thread->save()) {
114 114
             return redirect(route('doctor.thread.show', $id))->with('success', 'Perubahan jawaban terkirim !');
115 115
         }
116 116
         return redirect()->back()->with('failed', 'Gagal mengirim perubahan jawaban.');
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
     public function destroy($id)
126 126
     {
127 127
         $thread = Thread::find($id);
128
-        if($thread->doctor_id != $this->currentUser()->id) {
128
+        if ($thread->doctor_id != $this->currentUser()->id) {
129 129
             return redirect()->back()->with('warning', 'Anda tidak berhak menghapus jawaban untuk diskusi tersebut.');
130 130
         }
131 131
 
132 132
         $thread->doctor_id = null;
133 133
         $thread->answer = null;
134 134
         $thread->status = false;
135
-        if($thread->save()) {
135
+        if ($thread->save()) {
136 136
             return redirect()->back()->with('success', 'Jawaban dihapus !');
137 137
         }
138 138
         return redirect()->back()->with('failed', 'Gagal mengahapus jawaban.');
Please login to merge, or discard this patch.
app/Http/Controllers/ThreadAskController.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function __construct()
14 14
     {
15
-        $this->middleware('auth', ['except' => [
15
+        $this->middleware('auth', [ 'except' => [
16 16
             'index', 'show'
17
-        ]]);
17
+        ] ]);
18 18
     }
19 19
 
20 20
 
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 
63 63
         $topic = $this->addTopic($request->input('topic'));
64 64
 
65
-        if($topic != null) {
65
+        if ($topic != null) {
66 66
             $thread = new Thread;
67 67
             $thread->user_id = $this->currentUser()->id;
68 68
             $thread->id_topic = $topic->id;
69 69
             $thread->question = $request->input('question');
70 70
 
71 71
             $log = null;
72
-            if($thread->save()) {
72
+            if ($thread->save()) {
73 73
                 $log = Common::registerLog([
74 74
                     'action' => "membuat diskusi baru.",
75 75
                     'target' => 'thread',
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 ]);
81 81
             }
82 82
 
83
-            if($log != null && $log == true) {
83
+            if ($log != null && $log == true) {
84 84
                 return redirect(route('user.thread.index'))->with('success', 'Pertanyaan dikirim !');
85 85
             }
86 86
             return redirect()->back()->with('failed', 'Gagal mengirim pertanyaan, silahkan coba lagi nanti.');
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     public function show($id)
98 98
     {
99 99
         $thread = Thread::find($id);
100
-        if(!$thread) {
100
+        if (!$thread) {
101 101
             abort(404);
102 102
         }
103 103
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
     {
120 120
         $user = $this->currentUser();
121 121
         $thread = Thread::find($id);
122
-        if($thread->user_id != $user->id) {
122
+        if ($thread->user_id != $user->id) {
123 123
             return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.');
124 124
         }
125 125
 
126
-        if($thread->doctor_id != null) {
126
+        if ($thread->doctor_id != null) {
127 127
             return redirect()->back()->with('warning', 'Tidak dapat mengubah pertanyaan karena sudah terjawab, silahkan tanyakan pertanyaan baru.');
128 128
         }
129 129
         $threads = Thread::orderBy('created_at', 'desc')->paginate(5);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $user = $this->currentUser();
150 150
         $thread = Thread::find($id);
151
-        if($thread->user_id != $user->id) {
151
+        if ($thread->user_id != $user->id) {
152 152
             return redirect()->back()->with('warning', 'Anda tidak berhak mengubah ulasan tersebut.');
153 153
         }
154 154
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
         $thread->topic = $request->input('topic');
161 161
         $thread->question = $request->input('question');
162
-        if($thread->save()) {
162
+        if ($thread->save()) {
163 163
             return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !');
164 164
         }
165 165
         return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !');
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
     {
176 176
         $user = $this->currentUser();
177 177
         $thread = Thread::find($id);
178
-        if($thread->user_id != $user->id) {
178
+        if ($thread->user_id != $user->id) {
179 179
             return redirect()->back()->with('warning', 'Anda tidak berhak menghapus ulasan tersebut.');
180 180
         }
181 181
 
182
-        if($thread->delete() && $this->deleteTopic($thread->id_topic)) {
182
+        if ($thread->delete() && $this->deleteTopic($thread->id_topic)) {
183 183
             return redirect(route('user.profile'))->with('success', 'Ulasan dihapus !');
184 184
         }
185 185
         return redirect()->back()->with('failed', 'Gagal menghapus ulasan.');
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         $new = new ThreadTopic;
205 205
         $new->topic_name = $topic;
206
-        if($new->save()) {
206
+        if ($new->save()) {
207 207
             return $new;
208 208
         }
209 209
         return null;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     private function deleteTopic($id)
219 219
     {
220 220
         $topic = ThreadTopic::find($id);
221
-        if($topic->delete()) {
221
+        if ($topic->delete()) {
222 222
             return true;
223 223
         }
224 224
         return false;
Please login to merge, or discard this patch.
app/Http/Controllers/AdminController.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             'role' => session('role'),
55 55
             'admin' => $admin,
56 56
         ];
57
-        return view('pages.admin')->with('data',$data);
57
+        return view('pages.admin')->with('data', $data);
58 58
     }
59 59
 
60 60
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $data = [
68 68
             'role' => session('role')
69 69
         ];
70
-        return view ('pages.ext.add-admin')->with('data',$data);
70
+        return view('pages.ext.add-admin')->with('data', $data);
71 71
     }
72 72
 
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function store(Request $request)
80 80
     {
81
-        $this->validate($request,[
81
+        $this->validate($request, [
82 82
             'name' => 'required|min:3|max:50',
83 83
             'email' => 'required|email',
84 84
             'password' => 'required_with:password_confirmation|same:password_confirmation|min:6',
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
         $admin->email = $request->input('email');
91 91
         $admin->password = Hash::make($request->input('password'));
92 92
 
93
-        if($admin->save()) {
94
-            return redirect (route('admin.index'))->with('success', 'Admin berhasil di tambahkan !');
93
+        if ($admin->save()) {
94
+            return redirect(route('admin.index'))->with('success', 'Admin berhasil di tambahkan !');
95 95
         }
96 96
 
97
-        return redirect (route('admin.index'))->with('failed', 'Gagal menambah admin !');
97
+        return redirect(route('admin.index'))->with('failed', 'Gagal menambah admin !');
98 98
     }
99 99
 
100 100
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 
153 153
             $img = null;
154 154
 
155
-            if($request->hasFile('profile_picture')) {
155
+            if ($request->hasFile('profile_picture')) {
156 156
 
157
-                if( $admin->profile_picture != "user-default.jpg") {
157
+                if ($admin->profile_picture != "user-default.jpg") {
158 158
                     Storage::delete('public/user_images/'.$admin->profile_picture);
159 159
                 }
160 160
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
             $admin->name = $request->input('name');
174 174
             $admin->email = $request->input('email');
175
-            if($request->hasFile('profile_picture')) {
175
+            if ($request->hasFile('profile_picture')) {
176 176
                 $admin->profile_picture = $img;
177 177
             }
178 178
             $admin->save();
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function editPass($id)
192 192
     {
193 193
         $admin = $this->currentUser();
194
-        if($admin->id == $id) {
194
+        if ($admin->id == $id) {
195 195
             $data = [
196 196
                 'admin' => $admin
197 197
             ];
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     public function updatePass(Request $request, $id)
212 212
     {
213 213
         $admin = $this->currentUser();
214
-        if($admin->id == $id) {
214
+        if ($admin->id == $id) {
215 215
 
216 216
             $this->validate($request, [
217 217
                 'old_password' => 'required|min:6',
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                 'password_confirmation' => 'required|min:6'
220 220
             ]);
221 221
 
222
-            if($this->validatePass($request->input('old_password'))) {
222
+            if ($this->validatePass($request->input('old_password'))) {
223 223
                 $admin->password = Hash::make($request->input('new_password'));
224 224
                 $admin->save();
225 225
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     public function log($id)
236 236
     {
237 237
         $admin = $this->currentUser();
238
-        if($admin->id == $id) {
238
+        if ($admin->id == $id) {
239 239
             $data = [
240 240
                 'admin' => $admin,
241 241
                 'logs' => Log::orderBy('created_at', 'desc')->paginate(10)
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
     public function removeImage()
254 254
     {
255 255
         $admin = $this->currentUser();
256
-        if($admin->profile_picture != "user-default.jpg") {
256
+        if ($admin->profile_picture != "user-default.jpg") {
257 257
             Storage::delete('public/user_images/'.$admin->profile_picture);
258 258
         }
259 259
 
260 260
         $admin->profile_picture = "user-default.jpg";
261
-        if($admin->save()) {
261
+        if ($admin->save()) {
262 262
             return redirect(route('admin.profile.edit', $admin->id))->with('success', 'Foto profil berhasil dihapus !');
263 263
         }
264 264
     }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function destroy() {
271 271
         $admin = $this->currentUser();
272 272
 
273
-        if($admin->delete()) {
273
+        if ($admin->delete()) {
274 274
 
275 275
             session()->flush();
276 276
             return redirect(route('admin.login', $admin->id))->with('success', 'Akun berhasil dihapus !');
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     private function validatePass(string $oldPassword)
297 297
     {
298 298
         $admin = $this->currentUser();
299
-        if(Hash::check($oldPassword, $admin->password)) {
299
+        if (Hash::check($oldPassword, $admin->password)) {
300 300
             return true;
301 301
         }
302 302
 
Please login to merge, or discard this patch.
app/Http/Controllers/ArticleController.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      */
16 16
     public function index()
17 17
     {
18
-        $articles = Articles::orderBy('category','asc')->paginate(15);
18
+        $articles = Articles::orderBy('category', 'asc')->paginate(15);
19 19
         $data = [
20 20
             'articles' => $articles
21 21
         ];
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function store(Request $request)
40 40
     {
41
-        $this->validate($request,[
41
+        $this->validate($request, [
42 42
             'category' => 'required',
43 43
             'title' => 'required',
44 44
             'content' => 'required|min:500',
45 45
             'cover_image' => 'image|nullable|max:3999'
46 46
         ]);
47 47
 
48
-        if($request->hasFile('cover_image')){
48
+        if ($request->hasFile('cover_image')) {
49 49
             $filenameWithExt = $request->file('cover_image')->getClientOriginalName();
50 50
             $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
51 51
             $extension = $request->file('cover_image')->getClientOriginalExtension();
52 52
             $fileNameToStore = $filename.'_'.time().'.'.$extension;
53 53
             $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore);
54
-        }else {
54
+        } else {
55 55
             $fileNameToStore = 'noimage.jpg';
56 56
         }
57 57
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $article->category = $request->input('category');
60 60
         $article->title = $request->input('title');
61 61
         $article->content = $request->input('content');
62
-        if(session('guard') == 'admin') {
62
+        if (session('guard') == 'admin') {
63 63
             $article->admin_id = Auth::guard('admin')->user()->id;
64 64
         } else {
65 65
             $article->doctor_id = Auth::guard('doctor')->user()->id;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $article->cover_image = $fileNameToStore;
68 68
 
69 69
         $log = null;
70
-        if($article->save()) {
70
+        if ($article->save()) {
71 71
             $log = Common::registerLog([
72 72
                 'action' => "membuat artikel baru.",
73 73
                 'target' => 'article',
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
             ]);
79 79
         }
80 80
 
81
-        if($log != null && $log == true) {
82
-            return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !');
81
+        if ($log != null && $log == true) {
82
+            return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !');
83 83
         }
84 84
 
85 85
         return redirect(route(session('guard').'.article.create'))->with('failed', 'Gagal menambahkan artikel.');
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function show($id)
93 93
     {
94 94
         $article = Articles::find($id);
95
-        if(!$article) {
95
+        if (!$article) {
96 96
             abort(404);
97 97
         }
98 98
         return view('pages.ext.view-article')->with('article', $article);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         }
126 126
 
127 127
         $data = [
128
-            'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(),
128
+            'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(),
129 129
             'category' => $category,
130 130
             'cat' => $cat
131 131
         ];
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
         }
157 157
             $data = [
158 158
                 'articles' => Articles::where('category', $cat)
159
-                                        ->where('title','LIKE',$name.'%')
160
-                                        ->orderBy('title','asc')
159
+                                        ->where('title', 'LIKE', $name.'%')
160
+                                        ->orderBy('title', 'asc')
161 161
                                         ->get(),
162 162
                 'category' => $category,
163 163
                 'cat' => $cat
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
     {
171 171
         $cari = $request->cari;
172 172
         $articles = Articles::where('category', $cat)
173
-                        ->where('content','LIKE','%'.$cari.'%')
174
-                        ->orderBy('title','asc')
173
+                        ->where('content', 'LIKE', '%'.$cari.'%')
174
+                        ->orderBy('title', 'asc')
175 175
                         ->get();
176 176
         $category = null;
177 177
         switch ($cat) {
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
     public function edit($id)
208 208
     {
209 209
         $article = Articles::find($id);
210
-        if(!$article) {
210
+        if (!$article) {
211 211
             abort(404);
212 212
         }
213 213
 
214
-        if($article->writer()['data']->id != Auth::guard(session('guard'))->user()->id) {
214
+        if ($article->writer()[ 'data' ]->id != Auth::guard(session('guard'))->user()->id) {
215 215
             return redirect(session('guard').'/article')->with('warning', 'Anda tidak berhak untuk mengubah Artikel tersebut.');
216 216
         }
217 217
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public function update(Request $request, $id)
231 231
     {
232
-        $this->validate($request,[
232
+        $this->validate($request, [
233 233
             'category' => 'required',
234 234
             'title' => 'required',
235 235
             'content' => 'required|min:500',
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         ]);
239 239
 
240
-        if($request->hasFile('cover_image')){
240
+        if ($request->hasFile('cover_image')) {
241 241
             $filenameWithExt = $request->file('cover_image')->getClientOriginalName();
242 242
             $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
243 243
             $extension = $request->file('cover_image')->getClientOriginalExtension();
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
         $article->category = $request->input('category');
250 250
         $article->title = $request->input('title');
251 251
         $article->content = $request->input('content');
252
-        if($request->hasFile('cover_image')){
252
+        if ($request->hasFile('cover_image')) {
253 253
             $article->cover_image = $fileNameToStore;
254 254
         }
255 255
 
256
-        if($article->save()) {
257
-            return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !');
256
+        if ($article->save()) {
257
+            return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !');
258 258
         }
259 259
 
260
-        return redirect (route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !');
260
+        return redirect(route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !');
261 261
     }
262 262
 
263 263
     /**
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
     {
269 269
         $article = Articles::find($id);
270 270
 
271
-        if($article->cover_image != 'noimage.jpg'){
271
+        if ($article->cover_image != 'noimage.jpg') {
272 272
             Storage::delete('public/cover_images/'.$article->cover_image);
273 273
         }
274 274
 
275
-        if($article->delete()) {
275
+        if ($article->delete()) {
276 276
             return redirect()->back()->with('success', 'Artikel dihapus !');
277 277
         }
278 278
 
Please login to merge, or discard this patch.
app/Common.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,22 +16,22 @@
 block discarded – undo
16 16
     public static function registerLog($data) {
17 17
         $log = new Log;
18 18
 
19
-        $log->action = $data['action'];
20
-        $log->target = $data['target'];
21
-        $log->prefix = $data['prefix'];
19
+        $log->action = $data[ 'action' ];
20
+        $log->target = $data[ 'target' ];
21
+        $log->prefix = $data[ 'prefix' ];
22 22
 
23
-        switch($data['target']) {
24
-            case 'thread'   : $log->thread_id = $data['target_id']; break;
25
-            case 'article'  : $log->article_id = $data['target_id']; break;
23
+        switch ($data[ 'target' ]) {
24
+            case 'thread'   : $log->thread_id = $data[ 'target_id' ]; break;
25
+            case 'article'  : $log->article_id = $data[ 'target_id' ]; break;
26 26
         }
27 27
 
28
-        switch ($data['actor']) {
29
-            case 'admin'    : $log->admin_id = $data['actor_id'];   break;
30
-            case 'doctor'   : $log->doctor_id = $data['actor_id'];  break;
31
-            case 'user'     : $log->user_id = $data['actor_id'];  break;
28
+        switch ($data[ 'actor' ]) {
29
+            case 'admin'    : $log->admin_id = $data[ 'actor_id' ]; break;
30
+            case 'doctor'   : $log->doctor_id = $data[ 'actor_id' ]; break;
31
+            case 'user'     : $log->user_id = $data[ 'actor_id' ]; break;
32 32
         }
33 33
 
34
-        if($log->save()) {
34
+        if ($log->save()) {
35 35
             return true;
36 36
         }
37 37
 
Please login to merge, or discard this patch.