Completed
Push — master ( 634be5...2c8eb1 )
by Sherif
10:27
created
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.
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 1 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.