Completed
Push — master ( 1e8b34...bf4aa0 )
by Sherif
02:38
created
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,8 +170,7 @@
 block discarded – undo
170 170
             if ($request->has('id')) 
171 171
             {
172 172
                 $rule = str_replace('{id}', $request->get('id'), $rule);
173
-            }
174
-            else
173
+            } else
175 174
             {
176 175
                 $rule = str_replace(',{id}', '', $rule);
177 176
             }
Please login to merge, or discard this patch.
Doc Comments   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     /**
62 62
      * Fetch all records with relations from model repository.
63 63
      * 
64
-     * @return \Illuminate\Http\Response
64
+     * @return \Illuminate\Http\JsonResponse|null
65 65
      */
66 66
     public function index() 
67 67
     {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * Fetch the single object with relations from model repository.
77 77
      * 
78 78
      * @param  integer $id
79
-     * @return \Illuminate\Http\Response
79
+     * @return \Illuminate\Http\JsonResponse|null
80 80
      */
81 81
     public function find($id) 
82 82
     {
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
      * @param  string  $query
95 95
      * @param  integer $perPage
96 96
      * @param  string  $sortBy
97
-     * @param  boolean $desc
98
-     * @return \Illuminate\Http\Response
97
+     * @param  integer $desc
98
+     * @return \Illuminate\Http\JsonResponse|null
99 99
      */
100 100
     public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
101 101
     {
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      * 
113 113
      * @param  \Illuminate\Http\Request  $request
114 114
      * @param  string  $sortBy
115
-     * @param  boolean $desc
116
-     * @return \Illuminate\Http\Response
115
+     * @param  integer $desc
116
+     * @return \Illuminate\Http\JsonResponse|null
117 117
      */
118 118
     public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
119 119
     {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      * condition.
130 130
      * 
131 131
      * @param  \Illuminate\Http\Request  $request
132
-     * @return \Illuminate\Http\Response
132
+     * @return \Illuminate\Http\JsonResponse|null
133 133
      */
134 134
     public function first(Request $request) 
135 135
     {
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
      * 
146 146
      * @param  integer $perPage
147 147
      * @param  string  $sortBy
148
-     * @param  boolean $desc
149
-     * @return \Illuminate\Http\Response
148
+     * @param  integer $desc
149
+     * @return \Illuminate\Http\JsonResponse|null
150 150
      */
151 151
     public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
152 152
     {
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
      * @param  \Illuminate\Http\Request  $request
165 165
      * @param  integer $perPage
166 166
      * @param  string  $sortBy
167
-     * @param  boolean $desc
168
-     * @return \Illuminate\Http\Response
167
+     * @param  integer $desc
168
+     * @return \Illuminate\Http\JsonResponse|null
169 169
      */
170 170
     public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
171 171
     {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * Save the given model to repository.
181 181
      * 
182 182
      * @param  \Illuminate\Http\Request  $request
183
-     * @return \Illuminate\Http\Response
183
+     * @return \Illuminate\Http\JsonResponse|null
184 184
      */
185 185
     public function save(Request $request) 
186 186
     {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * Delete by the given id from model repository.
214 214
      * 
215 215
      * @param  integer  $id
216
-     * @return \Illuminate\Http\Response
216
+     * @return \Illuminate\Http\JsonResponse|null
217 217
      */
218 218
     public function delete($id) 
219 219
     {
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
      * @param  \Illuminate\Http\Request  $request
230 230
      * @param  integer $perPage
231 231
      * @param  string  $sortBy
232
-     * @param  boolean $desc
233
-     * @return \Illuminate\Http\Response
232
+     * @param  integer $desc
233
+     * @return \Illuminate\Http\JsonResponse
234 234
      */
235 235
     public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
236 236
     {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      * Restore the deleted model.
242 242
      * 
243 243
      * @param  integer  $id
244
-     * @return \Illuminate\Http\Response
244
+     * @return \Illuminate\Http\JsonResponse|null
245 245
      */
246 246
     public function restore($id) 
247 247
     {
Please login to merge, or discard this patch.
src/Modules/V1/Reporting/Repositories/ReportRepository.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@  discard block
 block discarded – undo
38 38
         if ( ! $report) 
39 39
         {
40 40
             \ErrorHandler::notFound('report');
41
-        }
42
-        else if ( ! \Core::users()->can($report->view_name, 'reports'))
41
+        } else if ( ! \Core::users()->can($report->view_name, 'reports'))
43 42
         {
44 43
             \ErrorHandler::noPermissions();
45 44
         }
@@ -60,8 +59,7 @@  discard block
 block discarded – undo
60 59
         if ($perPage) 
61 60
         {
62 61
             return $report->paginate($perPage);
63
-        }
64
-        else
62
+        } else
65 63
         {
66 64
             return $report->get();  
67 65
         }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -103,24 +103,19 @@  discard block
 block discarded – undo
103 103
         if ( ! $user = $this->first(['email' => $credentials['email']])) 
104 104
         {
105 105
             \ErrorHandler::loginFailed();
106
-        }
107
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
106
+        } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108 107
         {
109 108
             \ErrorHandler::loginFailed();
110
-        }
111
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
109
+        } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112 110
         {
113 111
             \ErrorHandler::loginFailed();
114
-        }
115
-        else if ($user->blocked)
112
+        } else if ($user->blocked)
116 113
         {
117 114
             \ErrorHandler::userIsBlocked();
118
-        }
119
-        else if ($token = \JWTAuth::attempt($credentials))
115
+        } else if ($token = \JWTAuth::attempt($credentials))
120 116
         {
121 117
             return ['token' => $token];
122
-        }
123
-        else
118
+        } else
124 119
         {
125 120
             \ErrorHandler::loginFailed();
126 121
         }
@@ -146,8 +141,7 @@  discard block
 block discarded – undo
146 141
         {
147 142
             $data = ['email' => $user->email, 'password' => ''];
148 143
             return $this->register($data);
149
-        }
150
-        else
144
+        } else
151 145
         {
152 146
             if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153 147
             {
@@ -193,12 +187,10 @@  discard block
 block discarded – undo
193 187
         if ( ! $this->hasGroup('Admin'))
194 188
         {
195 189
             \ErrorHandler::noPermissions();
196
-        }
197
-        else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
190
+        } else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198 191
         {
199 192
             \ErrorHandler::noPermissions();
200
-        }
201
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
193
+        } else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202 194
         {
203 195
             \ErrorHandler::noPermissions();
204 196
         }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/UsersController.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,8 +170,7 @@
 block discarded – undo
170 170
             if ($request->has('id')) 
171 171
             {
172 172
                 $rule = str_replace('{id}', $request->get('id'), $rule);
173
-            }
174
-            else
173
+            } else
175 174
             {
176 175
                 $rule = str_replace(',{id}', '', $rule);
177 176
             }
Please login to merge, or discard this patch.
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 2 patches
Doc Comments   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @param  array   $relations
34 34
      * @param  string  $sortBy
35
-     * @param  boolean $desc
35
+     * @param  integer $desc
36 36
      * @param  array   $columns
37 37
      * @return collection
38 38
      */
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param  integer $perPage
51 51
      * @param  array   $relations
52 52
      * @param  string  $sortBy
53
-     * @param  boolean $desc
53
+     * @param  integer $desc
54 54
      * @param  array   $columns
55 55
      * @return collection
56 56
      */
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @param  integer $perPage
140 140
      * @param  array   $relations
141 141
      * @param  string  $sortBy
142
-     * @param  boolean $desc
142
+     * @param  integer $desc
143 143
      * @param  array   $columns
144 144
      * @return collection
145 145
      */
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @param  integer $perPage
158 158
      * @param  array   $relations
159 159
      * @param  string  $sortBy
160
-     * @param  boolean $desc
160
+     * @param  integer $desc
161 161
      * @param  array   $columns
162 162
      * @return collection
163 163
      */
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      * Update record in the storage based on the given
419 419
      * condition.
420 420
      * 
421
-     * @param  var $value condition value
421
+     * @param  boolean $value condition value
422 422
      * @param  array $data
423 423
      * @param  string $attribute condition column name
424 424
      * @return void
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
      * id.
480 480
      * 
481 481
      * @param  integer $id
482
-     * @param  array   $relations
482
+     * @param  string[]   $relations
483 483
      * @param  array   $columns
484 484
      * @return object
485 485
      */
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
      * @param  array   $conditions array of conditions
496 496
      * @param  array   $relations
497 497
      * @param  string  $sortBy
498
-     * @param  boolean $desc
498
+     * @param  integer $desc
499 499
      * @param  array   $columns
500 500
      * @return collection
501 501
      */
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
      * @param  array   $conditions array of conditions
528 528
      * @param  integer $perPage
529 529
      * @param  string  $sortBy
530
-     * @param  boolean $desc
530
+     * @param  integer $desc
531 531
      * @param  array   $columns
532 532
      * @return collection
533 533
      */
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -430,8 +430,7 @@  discard block
 block discarded – undo
430 430
             $model = $this->model->lockForUpdate()->find($value);
431 431
             $model ? $model->update($data) : 0;
432 432
             $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false;
433
-        }
434
-        else
433
+        } else
435 434
         {
436 435
             call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
437 436
                 $model->update($data);
@@ -462,8 +461,7 @@  discard block
 block discarded – undo
462 461
                 $model->delete();
463 462
                 $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false;
464 463
             });
465
-        }
466
-        else
464
+        } else
467 465
         {
468 466
             \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
469 467
                 call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){
@@ -580,14 +578,12 @@  discard block
 block discarded – undo
580 578
                 $conditions       = $this->constructConditions($value, $model);
581 579
                 $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} ';
582 580
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
583
-            }
584
-            else if ($key == 'or')
581
+            } else if ($key == 'or')
585 582
             {
586 583
                 $conditions       = $this->constructConditions($value, $model);
587 584
                 $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} ';
588 585
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
589
-            }
590
-            else
586
+            } else
591 587
             {
592 588
                 if (is_array($value)) 
593 589
                 {
@@ -596,13 +592,11 @@  discard block
 block discarded – undo
596 592
                     {
597 593
                         $value1 = $value['val1'];
598 594
                         $value2 = $value['val2'];
599
-                    }
600
-                    else
595
+                    } else
601 596
                     {
602 597
                         $value = array_key_exists('val', $value) ? $value['val'] : '';
603 598
                     }
604
-                }
605
-                else
599
+                } else
606 600
                 {
607 601
                     $operator = '=';
608 602
                 }
@@ -614,29 +608,24 @@  discard block
 block discarded – undo
614 608
 
615 609
                     $conditionString  .= $key . ' <= ? {op} ';
616 610
                     $conditionValues[] = $value2;
617
-                }
618
-                elseif (strtolower($operator) == 'in') 
611
+                } elseif (strtolower($operator) == 'in') 
619 612
                 {
620 613
                     $conditionValues  = array_merge($conditionValues, $value);
621 614
                     $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
622 615
                     $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} ';
623
-                }
624
-                elseif (strtolower($operator) == 'null') 
616
+                } elseif (strtolower($operator) == 'null') 
625 617
                 {
626 618
                     $conditionString .= $key . ' is null {op} ';
627
-                }
628
-                elseif (strtolower($operator) == 'not null') 
619
+                } elseif (strtolower($operator) == 'not null') 
629 620
                 {
630 621
                     $conditionString .= $key . ' is not null {op} ';
631
-                }
632
-                elseif (strtolower($operator) == 'has') 
622
+                } elseif (strtolower($operator) == 'has') 
633 623
                 {
634 624
                     $sql              = $model->withTrashed()->has($key)->toSql();
635 625
                     $conditions       = $this->constructConditions($value, $model->first()->$key);
636 626
                     $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ')';
637 627
                     $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
638
-                }
639
-                else
628
+                } else
640 629
                 {
641 630
                     $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
642 631
                     $conditionValues[] = $value;
Please login to merge, or discard this patch.