Completed
Push — master ( 4b6f70...bf5864 )
by Sherif
02:04
created
src/Modules/Core/BaseClasses/BaseService.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $translatable = $this->repo->model->translatable ?? [];
40 40
         $filters = $this->constructFilters($conditions);
41
-        $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . Session::get('locale') : $sortBy;
41
+        $sortBy = in_array($sortBy, $translatable) ? $sortBy.'->'.Session::get('locale') : $sortBy;
42 42
 
43 43
         if ($trashed) {
44 44
             return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 /**
207 207
                  * Prepare key based on the the requested lang if it was translatable.
208 208
                  */
209
-                $key = in_array($key, $translatable) ? $key . '->' . (Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
209
+                $key = in_array($key, $translatable) ? $key.'->'.(Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
210 210
 
211 211
                 /**
212 212
                  * Convert 0/1 or true/false to boolean in case of not foreign key.
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 /**
218 218
                  * Use in operator in case of foreign and comma seperated values.
219 219
                  */
220
-                } elseif (! is_array($value) && strpos($key, '_id') && $value) {
220
+                } elseif ( ! is_array($value) && strpos($key, '_id') && $value) {
221 221
                     $filters[$key] = [
222 222
                         'op' => 'in',
223 223
                         'val' => explode(',', $value)
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
                  * Default string filteration.
242 242
                  */
243 243
                 } elseif ($value) {
244
-                    $key = 'LOWER(' . $key . ')';
244
+                    $key = 'LOWER('.$key.')';
245 245
                     $value = strtolower($value);
246 246
                     $filters[$key] = [
247 247
                         'op' => 'like',
248
-                        'val' => '%' . $value . '%'
248
+                        'val' => '%'.$value.'%'
249 249
                     ];
250 250
                 }
251 251
             }
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseRepository.php 1 patch
Spacing   +13 added lines, -13 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
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function count($conditions = false)
84 84
     {
85
-        if($conditions) {
85
+        if ($conditions) {
86 86
             $conditions = $this->constructConditions($conditions, $this->model);
87 87
             return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
88 88
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $model      = false;
117 117
         $relations  = [];
118 118
 
119
-        \DB::transaction(function () use (&$model, &$relations, $data) {
119
+        \DB::transaction(function() use (&$model, &$relations, $data) {
120 120
             
121 121
             $model     = $this->prepareModel($data);
122 122
             $relations = $this->prepareRelations($data, $model);
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function delete($value, $attribute = 'id')
154 154
     {
155
-        \DB::transaction(function () use ($value, $attribute) {
156
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
155
+        \DB::transaction(function() use ($value, $attribute) {
156
+            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) {
157 157
                 $model->delete();
158 158
             });
159 159
         });
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $model = $this->model->onlyTrashed()->find($id);
245 245
 
246
-        if (! $model) {
246
+        if ( ! $model) {
247 247
             \Errors::notFound(class_basename($this->model).' with id : '.$id);
248 248
         }
249 249
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
          * @var array
268 268
          */
269 269
         $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
270
-        if (! $model) {
270
+        if ( ! $model) {
271 271
             \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
272 272
         }
273 273
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
                      * If the relation has no value then marke the relation data
325 325
                      * related to the model to be deleted.
326 326
                      */
327
-                    if (! $value || ! count($value)) {
327
+                    if ( ! $value || ! count($value)) {
328 328
                         $relations[$relation] = 'delete';
329 329
                     }
330 330
                 }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
                          * Check if the relation is a collection.
343 343
                          */
344 344
                         if (class_basename($model->$relation) == 'Collection') {
345
-                            if (! is_array($val)) {
345
+                            if ( ! is_array($val)) {
346 346
                                 $relationModel = $relationBaseModel->lockForUpdate()->find($val);
347 347
                             } else {
348 348
                                 /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                             /**
356 356
                              * If model doesn't exists.
357 357
                              */
358
-                            if (! $relationModel) {
358
+                            if ( ! $relationModel) {
359 359
                                 \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
360 360
                             }
361 361
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                                 /**
394 394
                                  * If model doesn't exists.
395 395
                                  */
396
-                                if (! $relationModel) {
396
+                                if ( ! $relationModel) {
397 397
                                     \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
398 398
                                 }
399 399
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
                 } elseif (strtolower($operator) == 'has') {
580 580
                     $sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
581 581
                     $bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
582
-                    if($value) {
582
+                    if ($value) {
583 583
                         $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
584 584
                         $conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
585 585
                         $conditionValues  = array_merge($conditionValues, $bindings);
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
         $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
611 611
         $path       = explode('->', $value);
612 612
         $field      = array_shift($path);
613
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
613
+        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
614 614
             return '"'.$part.'"';
615 615
         })->implode('.'));
616 616
         
Please login to merge, or discard this patch.
src/Modules/Roles/Database/Seeds/RolesTableSeeder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
          */
21 21
         Role::updateOrInsert([
22 22
             'name' => RoleEnum::ADMIN,
23
-        ],[
23
+        ], [
24 24
             'created_at' => \DB::raw('NOW()'),
25 25
             'updated_at' => \DB::raw('NOW()')
26 26
         ]);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          */
31 31
         AclUser::firstOrCreate([
32 32
             'email' => '[email protected]',
33
-        ],[
33
+        ], [
34 34
             'name'       => 'Admin',
35 35
             'password'   => \Hash::make('123456'),
36 36
             'confirmed'  => 1,
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
         /**
42 42
          * Assign default users to admin roles.
43 43
          */
44
-        $adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id;;
44
+        $adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id; ;
45 45
         $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id;
46 46
         \DB::table('role_user')->updateOrInsert([
47 47
             'user_id' => $adminUserId,
48 48
             'role_id' => $adminRoleId,
49
-        ],[]);
49
+        ], []);
50 50
 
51 51
         /**
52 52
          * Insert the permissions related to roles table.
Please login to merge, or discard this patch.