Completed
Push — master ( 634be5...2c8eb1 )
by Sherif
10:27
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 2 patches
Doc Comments   +6 added lines, -7 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
      */
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
      * @param  array   $conditions array of conditions
497 497
      * @param  array   $relations
498 498
      * @param  string  $sortBy
499
-     * @param  boolean $desc
499
+     * @param  integer $desc
500 500
      * @param  array   $columns
501 501
      * @return collection
502 502
      */
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      * @param  array   $conditions array of conditions
529 529
      * @param  integer $perPage
530 530
      * @param  string  $sortBy
531
-     * @param  boolean $desc
531
+     * @param  integer $desc
532 532
      * @param  array   $columns
533 533
      * @return collection
534 534
      */
@@ -551,7 +551,6 @@  discard block
 block discarded – undo
551 551
      * Restore the deleted model.
552 552
      * 
553 553
      * @param  integer $id
554
-     * @param  string  $attribute condition column name
555 554
      * @return void
556 555
      */
557 556
     public function restore($id)
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         /**
64 64
          * Construct the select conditions for the model.
65 65
          */
66
-        $model->where(function ($q) use ($query, $conditionColumns, $relations){
66
+        $model->where(function($q) use ($query, $conditionColumns, $relations){
67 67
 
68 68
             if (count($conditionColumns)) 
69 69
             {
70 70
                 /**
71 71
                  * Use the first element in the model columns to construct the first condition.
72 72
                  */
73
-                $q->where(\DB::raw('LOWER(' . array_shift($conditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%');
73
+                $q->where(\DB::raw('LOWER('.array_shift($conditionColumns).')'), 'LIKE', '%'.strtolower($query).'%');
74 74
             }
75 75
 
76 76
             /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
              */
79 79
             foreach ($conditionColumns as $column) 
80 80
             {
81
-                $q->orWhere(\DB::raw('LOWER(' . $column . ')'), 'LIKE', '%' . strtolower($query) . '%');
81
+                $q->orWhere(\DB::raw('LOWER('.$column.')'), 'LIKE', '%'.strtolower($query).'%');
82 82
             }
83 83
 
84 84
             /**
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
                     /**
100 100
                      * Construct the relation condition.
101 101
                      */
102
-                    $q->orWhereHas($relation, function ($subModel) use ($query, $relation){
102
+                    $q->orWhereHas($relation, function($subModel) use ($query, $relation){
103 103
 
104
-                        $subModel->where(function ($q) use ($query, $relation){
104
+                        $subModel->where(function($q) use ($query, $relation){
105 105
 
106 106
                             /**
107 107
                              * Get columns of the relation.
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                                 /**
114 114
                                 * Use the first element in the relation model columns to construct the first condition.
115 115
                                  */
116
-                                $q->where(\DB::raw('LOWER(' . array_shift($subConditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%');
116
+                                $q->where(\DB::raw('LOWER('.array_shift($subConditionColumns).')'), 'LIKE', '%'.strtolower($query).'%');
117 117
                             }
118 118
 
119 119
                             /**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                              */
122 122
                             foreach ($subConditionColumns as $subConditionColumn)
123 123
                             {
124
-                                $q->orWhere(\DB::raw('LOWER(' . $subConditionColumn . ')'), 'LIKE', '%' . strtolower($query) . '%');
124
+                                $q->orWhere(\DB::raw('LOWER('.$subConditionColumn.')'), 'LIKE', '%'.strtolower($query).'%');
125 125
                             } 
126 126
                         });
127 127
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $modelClass = $this->model;
183 183
         $relations  = [];
184 184
 
185
-        \DB::transaction(function () use (&$model, &$relations, $data, $saveLog, $modelClass) {
185
+        \DB::transaction(function() use (&$model, &$relations, $data, $saveLog, $modelClass) {
186 186
             /**
187 187
              * If the id is present in the data then select the model for updating,
188 188
              * else create new model.
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
192 192
             if ( ! $model) 
193 193
             {
194
-                \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
194
+                \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']);
195 195
             }
196 196
 
197 197
             /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                                  */
250 250
                                 if ( ! $relationModel) 
251 251
                                 {
252
-                                    \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
252
+                                    \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
253 253
                                 }
254 254
 
255 255
                                 /**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                                     /**
261 261
                                      * Prevent the sub relations or attributes not in the fillable.
262 262
                                      */
263
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
263
+                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false)
264 264
                                     {
265 265
                                         $relationModel->$attr = $val;
266 266
                                     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                                      */
291 291
                                     if ( ! $relationModel) 
292 292
                                     {
293
-                                        \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
293
+                                        \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
294 294
                                     }
295 295
 
296 296
                                     foreach ($value as $relationAttribute => $relationValue) 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
         }
435 435
         else
436 436
         {
437
-            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
437
+            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){
438 438
                 $model->update($data);
439 439
                 $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
440 440
             });
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
     {
454 454
         if ($attribute == 'id') 
455 455
         {
456
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
456
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
457 457
                 $model = $this->model->lockForUpdate()->find($value);
458 458
                 if ( ! $model) 
459 459
                 {
460
-                    \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value);
460
+                    \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value);
461 461
                 }
462 462
                 
463 463
                 $model->delete();
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
         }
467 467
         else
468 468
         {
469
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
470
-                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
469
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
470
+                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) {
471 471
                     $model->delete();
472 472
                     $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
473 473
                 });
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     {
505 505
         $conditions = $this->constructConditions($conditions);
506 506
         $sort       = $desc ? 'desc' : 'asc';
507
-        return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
507
+        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
508 508
     }
509 509
 
510 510
     /**
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
             $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
545 545
         }
546 546
 
547
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);;
547
+        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ;
548 548
     }
549 549
 
550 550
     /**
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 
561 561
         if ( ! $model) 
562 562
         {
563
-            \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id);
563
+            \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id);
564 564
         }
565 565
 
566 566
         $model->restore();
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
         {
580 580
             if ($key == 'and') 
581 581
             {
582
-                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} ';
582
+                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']).' {op} ';
583 583
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
584 584
             }
585 585
             else if ($key == 'or')
586 586
             {
587
-                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} ';
587
+                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']).' {op} ';
588 588
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
589 589
             }
590 590
             else
@@ -609,20 +609,20 @@  discard block
 block discarded – undo
609 609
                 
610 610
                 if (strtolower($operator) == 'between') 
611 611
                 {
612
-                    $conditionString  .= $key . ' >= ? and ';
612
+                    $conditionString  .= $key.' >= ? and ';
613 613
                     $conditionValues[] = $value1;
614 614
 
615
-                    $conditionString  .= $key . ' <= ? {op} ';
615
+                    $conditionString  .= $key.' <= ? {op} ';
616 616
                     $conditionValues[] = $value2;
617 617
                 }
618 618
                 else
619 619
                 {
620
-                    $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
620
+                    $conditionString  .= $key.' '.$operator.' ? {op} ';
621 621
                     $conditionValues[] = $value;
622 622
                 }
623 623
             }
624 624
         }
625
-        $conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
625
+        $conditionString = '('.rtrim($conditionString, '{op} ').')';
626 626
         return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
627 627
     }
628 628
 
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 1 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.
V1/Reporting/Database/Migrations/2016_01_19_112603_sampel_report.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		DB::statement( "CREATE VIEW admin_count AS  
15
+		DB::statement("CREATE VIEW admin_count AS  
16 16
 			select count(u.id)
17 17
 			from users u, groups g ,users_groups ug
18 18
 			where
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function down()
41 41
 	{
42
-		DB::statement( "DROP VIEW IF EXISTS admin_count");
42
+		DB::statement("DROP VIEW IF EXISTS admin_count");
43 43
 	}
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.