Completed
Push — master ( cd8f65...e1eb39 )
by Sherif
27:44
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 1 patch
Spacing   +24 added lines, -24 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
             /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                                  */
251 251
                                 if ( ! $relationModel) 
252 252
                                 {
253
-                                    \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
253
+                                    \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
254 254
                                 }
255 255
 
256 256
                                 /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                                     /**
262 262
                                      * Prevent the sub relations or attributes not in the fillable.
263 263
                                      */
264
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
264
+                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false)
265 265
                                     {
266 266
                                         $relationModel->$attr = $val;
267 267
                                     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                                      */
290 290
                                     if ( ! $relationModel) 
291 291
                                     {
292
-                                        \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
292
+                                        \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
293 293
                                     }
294 294
 
295 295
                                     /**
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         }
429 429
         else
430 430
         {
431
-            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
431
+            call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){
432 432
                 $model->update($data);
433 433
                 $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
434 434
             });
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
     {
448 448
         if ($attribute == 'id') 
449 449
         {
450
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
450
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
451 451
                 $model = $this->model->lockForUpdate()->find($value);
452 452
                 if ( ! $model) 
453 453
                 {
454
-                    \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value);
454
+                    \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value);
455 455
                 }
456 456
                 
457 457
                 $model->delete();
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
         }
461 461
         else
462 462
         {
463
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
464
-                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
463
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
464
+                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) {
465 465
                     $model->delete();
466 466
                     $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
467 467
                 });
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     {
499 499
         $conditions = $this->constructConditions($conditions);
500 500
         $sort       = $desc ? 'desc' : 'asc';
501
-        return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
501
+        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
502 502
     }
503 503
 
504 504
     /**
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
         {
530 530
             if ($key == 'and') 
531 531
             {
532
-                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} ';
532
+                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']).' {op} ';
533 533
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
534 534
             }
535 535
             else if ($key == 'or')
536 536
             {
537
-                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} ';
537
+                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']).' {op} ';
538 538
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
539 539
             }
540 540
             else
@@ -559,20 +559,20 @@  discard block
 block discarded – undo
559 559
                 
560 560
                 if (strtolower($operator) == 'between') 
561 561
                 {
562
-                    $conditionString  .= $key . ' >= ? and ';
562
+                    $conditionString  .= $key.' >= ? and ';
563 563
                     $conditionValues[] = $value1;
564 564
 
565
-                    $conditionString  .= $key . ' <= ? {op} ';
565
+                    $conditionString  .= $key.' <= ? {op} ';
566 566
                     $conditionValues[] = $value2;
567 567
                 }
568 568
                 else
569 569
                 {
570
-                    $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
570
+                    $conditionString  .= $key.' '.$operator.' ? {op} ';
571 571
                     $conditionValues[] = $value;
572 572
                 }
573 573
             }
574 574
         }
575
-        $conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
575
+        $conditionString = '('.rtrim($conditionString, '{op} ').')';
576 576
         return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
577 577
     }
578 578
 
Please login to merge, or discard this patch.
V1/Notifications/Database/Migrations/2016_01_24_111941_notifications.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('notifications', function (Blueprint $table) {
15
+		Schema::create('notifications', function(Blueprint $table) {
16 16
 			$table->increments('id');
17 17
 			$table->string('key', 100);
18 18
             $table->text('data');
19
-			$table->string('item_name',100);
20
-			$table->string('item_type',100);
19
+			$table->string('item_name', 100);
20
+			$table->string('item_type', 100);
21 21
 			$table->integer('item_id');
22 22
 			$table->boolean('notified');
23 23
 			$table->softDeletes();
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Notification.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5 5
 
6
-class Notification extends Model{
6
+class Notification extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'notifications';
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     public function getDescriptionAttribute()
43 43
     {
44
-        return trans('notifications.' . $this->attributes['key'], unserialize($this->attributes['data']));
44
+        return trans('notifications.'.$this->attributes['key'], unserialize($this->attributes['data']));
45 45
     }
46 46
 
47 47
     public static function boot()
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Spacing   +6 added lines, -6 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->lists('permissions')->each(function ($permission) use (&$permissions, $model){
57
+        $user->groups->lists('permissions')->each(function($permission) use (&$permissions, $model){
58 58
             $permissions = array_merge($permissions, $permission->where('model', $model)->lists('name')->toArray()); 
59 59
         });
60 60
         
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function assignGroups($user_id, $group_ids)
84 84
     {
85
-        \DB::transaction(function () use ($user_id, $group_ids) {
85
+        \DB::transaction(function() use ($user_id, $group_ids) {
86 86
             $user = $this->find($user_id);
87 87
             $user->groups()->detach();
88 88
             $user->groups()->attach($group_ids);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             $view->with(['url' => $url]);
243 243
         });
244 244
 
245
-        $response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
245
+        $response = \Password::sendResetLink($email, function(\Illuminate\Mail\Message $message) {
246 246
             $message->subject('Your Password Reset Link');
247 247
         });
248 248
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     public function resetPassword($credentials)
263 263
     {
264 264
         $token    = false;
265
-        $response = \Password::reset($credentials, function ($user, $password) use (&$token) {
265
+        $response = \Password::reset($credentials, function($user, $password) use (&$token) {
266 266
             $user->password = bcrypt($password);
267 267
             $user->save();
268 268
 
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/GroupRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 */
24 24
 	public function assignPermissions($groupId, $permissionIds)
25 25
 	{
26
-		\DB::transaction(function () use ($groupId, $permissionIds) {
26
+		\DB::transaction(function() use ($groupId, $permissionIds) {
27 27
 			$group = $this->find($groupId);
28 28
 			$group->permissions()->detach();
29 29
 			$group->permissions()->attach($permissionIds);
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Migrations/2015_12_20_124153_users.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('users', function (Blueprint $table) {
15
+		Schema::create('users', function(Blueprint $table) {
16 16
             $table->increments('id');
17
-            $table->string('name',100);
17
+            $table->string('name', 100);
18 18
             $table->string('email')->unique();
19 19
             $table->string('password', 60);
20 20
             $table->boolean('blocked', 0);
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclUser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     use SoftDeletes;
10 10
     protected $table    = 'users';
11 11
     protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
-    protected $hidden   = ['password', 'remember_token','deleted_at'];
12
+    protected $hidden   = ['password', 'remember_token', 'deleted_at'];
13 13
     protected $guarded  = ['id'];
14 14
     protected $fillable = ['name', 'email', 'password'];
15 15
     public $searchable  = ['name', 'email'];
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function groups()
49 49
     {
50
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
50
+        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
51 51
     }
52 52
     
53 53
     public static function boot()
Please login to merge, or discard this patch.