Completed
Push — master ( 392340...6e5734 )
by Sherif
07:20
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @param  array   $relations
26 26
      * @param  string  $sortBy
27
-     * @param  boolean $desc
27
+     * @param  integer $desc
28 28
      * @param  array   $columns
29 29
      * @return collection
30 30
      */
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param  integer $perPage
43 43
      * @param  array   $relations
44 44
      * @param  string  $sortBy
45
-     * @param  boolean $desc
45
+     * @param  integer $desc
46 46
      * @param  array   $columns
47 47
      * @return collection
48 48
      */
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      * @param  integer $perPage
132 132
      * @param  array   $relations
133 133
      * @param  string  $sortBy
134
-     * @param  boolean $desc
134
+     * @param  integer $desc
135 135
      * @param  array   $columns
136 136
      * @return collection
137 137
      */
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @param  integer $perPage
150 150
      * @param  array   $relations
151 151
      * @param  string  $sortBy
152
-     * @param  boolean $desc
152
+     * @param  integer $desc
153 153
      * @param  array   $columns
154 154
      * @return collection
155 155
      */
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
      * Update record in the storage based on the given
413 413
      * condition.
414 414
      * 
415
-     * @param  var $value condition value
415
+     * @param  boolean $value condition value
416 416
      * @param  array $data
417 417
      * @param  string $attribute condition column name
418 418
      * @return void
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
      * @param  array   $conditions array of conditions
490 490
      * @param  array   $relations
491 491
      * @param  string  $sortBy
492
-     * @param  boolean $desc
492
+     * @param  integer $desc
493 493
      * @param  array   $columns
494 494
      * @return collection
495 495
      */
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      * @param  array   $conditions array of conditions
522 522
      * @param  integer $perPage
523 523
      * @param  string  $sortBy
524
-     * @param  boolean $desc
524
+     * @param  integer $desc
525 525
      * @param  array   $columns
526 526
      * @return collection
527 527
      */
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function __construct()
18 18
     {   
19
-        $this->model  = \App::make($this->getModel());
19
+        $this->model = \App::make($this->getModel());
20 20
     }
21 21
 
22 22
     /**
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
         /**
56 56
          * Construct the select conditions for the model.
57 57
          */
58
-        $model->where(function ($q) use ($query, $conditionColumns, $relations){
58
+        $model->where(function($q) use ($query, $conditionColumns, $relations){
59 59
 
60 60
             if (count($conditionColumns)) 
61 61
             {
62 62
                 /**
63 63
                  * Use the first element in the model columns to construct the first condition.
64 64
                  */
65
-                $q->where(\DB::raw('LOWER(' . array_shift($conditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%');
65
+                $q->where(\DB::raw('LOWER('.array_shift($conditionColumns).')'), 'LIKE', '%'.strtolower($query).'%');
66 66
             }
67 67
 
68 68
             /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
              */
71 71
             foreach ($conditionColumns as $column) 
72 72
             {
73
-                $q->orWhere(\DB::raw('LOWER(' . $column . ')'), 'LIKE', '%' . strtolower($query) . '%');
73
+                $q->orWhere(\DB::raw('LOWER('.$column.')'), 'LIKE', '%'.strtolower($query).'%');
74 74
             }
75 75
 
76 76
             /**
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     /**
92 92
                      * Construct the relation condition.
93 93
                      */
94
-                    $q->orWhereHas($relation, function ($subModel) use ($query, $relation){
94
+                    $q->orWhereHas($relation, function($subModel) use ($query, $relation){
95 95
 
96
-                        $subModel->where(function ($q) use ($query, $relation){
96
+                        $subModel->where(function($q) use ($query, $relation){
97 97
 
98 98
                             /**
99 99
                              * Get columns of the relation.
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                                 /**
106 106
                                 * Use the first element in the relation model columns to construct the first condition.
107 107
                                  */
108
-                                $q->where(\DB::raw('LOWER(' . array_shift($subConditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%');
108
+                                $q->where(\DB::raw('LOWER('.array_shift($subConditionColumns).')'), 'LIKE', '%'.strtolower($query).'%');
109 109
                             }
110 110
 
111 111
                             /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                              */
114 114
                             foreach ($subConditionColumns as $subConditionColumn)
115 115
                             {
116
-                                $q->orWhere(\DB::raw('LOWER(' . $subConditionColumn . ')'), 'LIKE', '%' . strtolower($query) . '%');
116
+                                $q->orWhere(\DB::raw('LOWER('.$subConditionColumn.')'), 'LIKE', '%'.strtolower($query).'%');
117 117
                             } 
118 118
                         });
119 119
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         $modelClass = $this->model;
175 175
         $relations  = [];
176 176
 
177
-        \DB::transaction(function () use (&$model, &$relations, $data, $saveLog, $modelClass) {
177
+        \DB::transaction(function() use (&$model, &$relations, $data, $saveLog, $modelClass) {
178 178
             /**
179 179
              * If the id is present in the data then select the model for updating,
180 180
              * else create new model.
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
184 184
             if ( ! $model) 
185 185
             {
186
-                \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
186
+                \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']);
187 187
             }
188 188
 
189 189
             /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                                  */
242 242
                                 if ( ! $relationModel) 
243 243
                                 {
244
-                                    \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
244
+                                    \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
245 245
                                 }
246 246
 
247 247
                                 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                                     /**
253 253
                                      * Prevent the sub relations or attributes not in the fillable.
254 254
                                      */
255
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
255
+                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false)
256 256
                                     {
257 257
                                         $relationModel->$attr = $val;
258 258
                                     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                                      */
283 283
                                     if ( ! $relationModel) 
284 284
                                     {
285
-                                        \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
285
+                                        \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
286 286
                                     }
287 287
 
288 288
                                     foreach ($value as $relationAttribute => $relationValue) 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
         }
428 428
         else
429 429
         {
430
-            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
430
+            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){
431 431
                 $model->update($data);
432 432
                 $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
433 433
             });
@@ -446,11 +446,11 @@  discard block
 block discarded – undo
446 446
     {
447 447
         if ($attribute == 'id') 
448 448
         {
449
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
449
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
450 450
                 $model = $this->model->lockForUpdate()->find($value);
451 451
                 if ( ! $model) 
452 452
                 {
453
-                    \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value);
453
+                    \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value);
454 454
                 }
455 455
                 
456 456
                 $model->delete();
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
         }
460 460
         else
461 461
         {
462
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
463
-                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){
462
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
463
+                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($saveLog){
464 464
                     $model->delete();
465 465
                     $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
466 466
                 });
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     {
498 498
         $conditions = $this->constructConditions($conditions, $this->model);
499 499
         $sort       = $desc ? 'desc' : 'asc';
500
-        return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
500
+        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
501 501
     }
502 502
 
503 503
     /**
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
             $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
538 538
         }
539 539
 
540
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);;
540
+        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ;
541 541
     }
542 542
 
543 543
     /**
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 
553 553
         if ( ! $model) 
554 554
         {
555
-            \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id);
555
+            \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id);
556 556
         }
557 557
 
558 558
         $model->restore();
@@ -572,13 +572,13 @@  discard block
 block discarded – undo
572 572
             if ($key == 'and') 
573 573
             {
574 574
                 $conditions       = $this->constructConditions($value, $model);
575
-                $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} ';
575
+                $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
576 576
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
577 577
             }
578 578
             else if ($key == 'or')
579 579
             {
580 580
                 $conditions       = $this->constructConditions($value, $model);
581
-                $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} ';
581
+                $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
582 582
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
583 583
             }
584 584
             else
@@ -603,41 +603,41 @@  discard block
 block discarded – undo
603 603
                 
604 604
                 if (strtolower($operator) == 'between') 
605 605
                 {
606
-                    $conditionString  .= $key . ' >= ? and ';
606
+                    $conditionString  .= $key.' >= ? and ';
607 607
                     $conditionValues[] = $value1;
608 608
 
609
-                    $conditionString  .= $key . ' <= ? {op} ';
609
+                    $conditionString  .= $key.' <= ? {op} ';
610 610
                     $conditionValues[] = $value2;
611 611
                 }
612 612
                 elseif (strtolower($operator) == 'in') 
613 613
                 {
614 614
                     $conditionValues  = array_merge($conditionValues, $value);
615 615
                     $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
616
-                    $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} ';
616
+                    $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
617 617
                 }
618 618
                 elseif (strtolower($operator) == 'null') 
619 619
                 {
620
-                    $conditionString .= $key . ' is null {op} ';
620
+                    $conditionString .= $key.' is null {op} ';
621 621
                 }
622 622
                 elseif (strtolower($operator) == 'not null') 
623 623
                 {
624
-                    $conditionString .= $key . ' is not null {op} ';
624
+                    $conditionString .= $key.' is not null {op} ';
625 625
                 }
626 626
                 elseif (strtolower($operator) == 'has') 
627 627
                 {
628 628
                     $sql              = $model->withTrashed()->has($key)->toSql();
629 629
                     $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
630
-                    $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} ';
630
+                    $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} ';
631 631
                     $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
632 632
                 }
633 633
                 else
634 634
                 {
635
-                    $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
635
+                    $conditionString  .= $key.' '.$operator.' ? {op} ';
636 636
                     $conditionValues[] = $value;
637 637
                 }
638 638
             }
639 639
         }
640
-        $conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
640
+        $conditionString = '('.rtrim($conditionString, '{op} ').')';
641 641
         return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
642 642
     }
643 643
 
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27 27
         foreach ($user->groups()->get() as $group)
28 28
         {
29
-            $group->permissions->each(function ($permission) use (&$permissions){
29
+            $group->permissions->each(function($permission) use (&$permissions){
30 30
                 $permissions[$permission->model][$permission->id] = $permission->name;
31 31
             });
32 32
         }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param  boolean $user
45 45
      * @return boolean
46 46
      */
47
-    public function can($nameOfPermission, $model, $user = false )
47
+    public function can($nameOfPermission, $model, $user = false)
48 48
     {      
49 49
         $user        = $user ?: \JWTAuth::parseToken()->authenticate();
50 50
         $permissions = [];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             \ErrorHandler::tokenExpired();
55 55
         }
56 56
 
57
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
57
+        $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model){
58 58
             $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59 59
         });
60 60
         
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param  integer $userId
69 69
      * @return boolean
70 70
      */
71
-    public function hasGroup($groupName, $userId = fa;se)
71
+    public function hasGroup($groupName, $userId = fa; se)
72 72
     {
73 73
         $userId = $userId ?: \JWTAuth::parseToken()->authenticate()->id;
74 74
         $groups = $this->find($userId)->groups;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function assignGroups($user_id, $group_ids)
86 86
     {
87
-        \DB::transaction(function () use ($user_id, $group_ids) {
87
+        \DB::transaction(function() use ($user_id, $group_ids) {
88 88
             $user = $this->find($user_id);
89 89
             $user->groups()->detach();
90 90
             $user->groups()->attach($group_ids);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $url   = $this->config['resetLink'];
248 248
         $token = \Password::getRepository()->create($user);
249 249
         
250
-        \Mail::send('Acl:resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
250
+        \Mail::send('Acl:resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function($m) use ($user) {
251 251
             $m->to($user->email, $user->name)->subject('Your Password Reset Link');
252 252
         });
253 253
     }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     public function resetPassword($credentials)
262 262
     {
263 263
         $token    = false;
264
-        $response = \Password::reset($credentials, function ($user, $password) use (&$token) {
264
+        $response = \Password::reset($credentials, function($user, $password) use (&$token) {
265 265
             $user->password = bcrypt($password);
266 266
             $user->save();
267 267
 
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Factories/UserFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Acl\AclUser::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Acl\AclUser::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'name'       => $faker->name(),
6 6
 		'email'      => $faker->safeEmail(),
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Factories/GroupFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Acl\AclGroup::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Acl\AclGroup::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'name'       => $faker->unique->word(),
6 6
 		'created_at' => $faker->dateTimeBetween('-1 years', 'now'),
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Factories/PermissionFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Acl\AclPermission::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Acl\AclPermission::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'name'       => $faker->randomElement(['save', 'delete', 'find', 'paginate']),
6 6
 		'model'      => $faker->randomElement(['users', 'groups', 'settings', 'notifications']),
Please login to merge, or discard this patch.
src/Modules/V1/Reporting/Database/Factories/ReportFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Reporting\Report::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Reporting\Report::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']),
6 6
 		'view_name'   => $faker->word(),
Please login to merge, or discard this patch.
V1/Notifications/Database/Factories/PushNotificationDeviceFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Notifications\PushNotificationDevice::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Notifications\PushNotificationDevice::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'device_token' => $faker->sha1(),
6 6
 		'device_type ' => $faker->randomElement(['android', 'ios']),
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Database/Factories/NotificationFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Notifications\Notification::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'key'         => $faker->randomElement(['low_stock', 'order_added', 'new_request']),
6 6
 		'item_name '  => $faker->randomElement(['User', 'Settings', 'Group']),
Please login to merge, or discard this patch.
src/Modules/V1/Core/Decorators/CachingDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         if ($this->cacheConfig && $this->cacheConfig == 'cache') 
65 65
         {
66 66
             $page     = \Request::get('page') !== null ? \Request::get('page') : '1';
67
-            $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments);
67
+            $cacheKey = $name.$page.\Session::get('locale').serialize($arguments);
68 68
             return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) {
69 69
                 return call_user_func_array([$this->repo, $name], $arguments);
70 70
             });
Please login to merge, or discard this patch.