Completed
Push — master ( b45468...dcac8e )
by Sherif
02:16
created
src/Modules/Core/BaseClasses/BaseRepository.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function __construct($model)
23 23
     {
24
-        $this->model  = $model;
24
+        $this->model = $model;
25 25
     }
26 26
 
27 27
     /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         /**
86 86
          * Construct the select conditions for the model.
87 87
          */
88
-        $model->where(function ($q) use ($query, $conditionColumns, $relations) {
88
+        $model->where(function($q) use ($query, $conditionColumns, $relations) {
89 89
 
90 90
             if (count($conditionColumns)) {
91 91
                 $column = 'LOWER('.array_shift($conditionColumns).')';
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
                     /**
128 128
                      * Construct the relation condition.
129 129
                      */
130
-                    $q->orWhereHas($relation, function ($subModel) use ($query, $relation) {
130
+                    $q->orWhereHas($relation, function($subModel) use ($query, $relation) {
131 131
 
132
-                        $subModel->where(function ($q) use ($query, $relation) {
132
+                        $subModel->where(function($q) use ($query, $relation) {
133 133
 
134 134
                             /**
135 135
                              * Get columns of the relation.
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $model      = false;
216 216
         $relations  = [];
217 217
 
218
-        \DB::transaction(function () use (&$model, $relations, $data) {
218
+        \DB::transaction(function() use (&$model, $relations, $data) {
219 219
             
220 220
             $model     = $this->prepareModel($data);
221 221
             $relations = $this->prepareRelations($data, $model);
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
     public function delete($value, $attribute = 'id')
237 237
     {
238 238
         if ($attribute == 'id') {
239
-            \DB::transaction(function () use ($value) {
239
+            \DB::transaction(function() use ($value) {
240 240
                 $model = $this->model->lockForUpdate()->find($value);
241
-                if (! $model) {
241
+                if ( ! $model) {
242 242
                     \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value);
243 243
                 }
244 244
                 
245 245
                 $model->delete();
246 246
             });
247 247
         } else {
248
-            \DB::transaction(function () use ($value, $attribute) {
249
-                $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
248
+            \DB::transaction(function() use ($value, $attribute) {
249
+                $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) {
250 250
                     $model->delete();
251 251
                 });
252 252
             });
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     {
338 338
         $model = $this->model->onlyTrashed()->find($id);
339 339
 
340
-        if (! $model) {
340
+        if ( ! $model) {
341 341
             \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id);
342 342
         }
343 343
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
          * @var array
362 362
          */
363 363
         $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
364
-        if (! $model) {
364
+        if ( ! $model) {
365 365
             \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']);
366 366
         }
367 367
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
                      * If the relation has no value then marke the relation data
412 412
                      * related to the model to be deleted.
413 413
                      */
414
-                    if (! $value || ! count($value)) {
414
+                    if ( ! $value || ! count($value)) {
415 415
                         $relations[$relation] = 'delete';
416 416
                     }
417 417
                 }
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                             /**
439 439
                              * If model doesn't exists.
440 440
                              */
441
-                            if (! $relationModel) {
441
+                            if ( ! $relationModel) {
442 442
                                 \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
443 443
                             }
444 444
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                                 /**
470 470
                                  * If model doesn't exists.
471 471
                                  */
472
-                                if (! $relationModel) {
472
+                                if ( ! $relationModel) {
473 473
                                     \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
474 474
                                 }
475 475
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
         $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
676 676
         $path       = explode('->', $value);
677 677
         $field      = array_shift($path);
678
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
678
+        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
679 679
             return '"'.$part.'"';
680 680
         })->implode('.'));
681 681
         
Please login to merge, or discard this patch.