@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | foreach ($fields as $field) { |
| 187 | 187 | if (in_array($field, $translatedAttributes)) { |
| 188 | - $query->orWhereHas('translations', function ($q) use ($field, $search) { |
|
| 188 | + $query->orWhereHas('translations', function($q) use ($field, $search) { |
|
| 189 | 189 | $q->where($field, $this->getLikeOperator(), "%{$search}%"); |
| 190 | 190 | }); |
| 191 | 191 | } else { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function create($fields) |
| 214 | 214 | { |
| 215 | - return DB::transaction(function () use ($fields) { |
|
| 215 | + return DB::transaction(function() use ($fields) { |
|
| 216 | 216 | $original_fields = $fields; |
| 217 | 217 | |
| 218 | 218 | $fields = $this->prepareFieldsBeforeCreate($fields); |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function update($id, $fields) |
| 269 | 269 | { |
| 270 | - DB::transaction(function () use ($id, $fields) { |
|
| 270 | + DB::transaction(function() use ($id, $fields) { |
|
| 271 | 271 | $object = $this->model->findOrFail($id); |
| 272 | 272 | |
| 273 | 273 | $this->beforeSave($object, $fields); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function updateBasic($id, $values, $scopes = []) |
| 292 | 292 | { |
| 293 | - return DB::transaction(function () use ($id, $values, $scopes) { |
|
| 293 | + return DB::transaction(function() use ($id, $values, $scopes) { |
|
| 294 | 294 | // apply scopes if no id provided |
| 295 | 295 | if (is_null($id)) { |
| 296 | 296 | $query = $this->model->query(); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $query->update($values); |
| 303 | 303 | |
| 304 | - $query->get()->each(function ($object) use ($values) { |
|
| 304 | + $query->get()->each(function($object) use ($values) { |
|
| 305 | 305 | $this->afterUpdateBasic($object, $values); |
| 306 | 306 | }); |
| 307 | 307 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $query = $this->model->whereIn('id', $id); |
| 314 | 314 | $query->update($values); |
| 315 | 315 | |
| 316 | - $query->get()->each(function ($object) use ($values) { |
|
| 316 | + $query->get()->each(function($object) use ($values) { |
|
| 317 | 317 | $this->afterUpdateBasic($object, $values); |
| 318 | 318 | }); |
| 319 | 319 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | public function setNewOrder($ids) |
| 338 | 338 | { |
| 339 | - DB::transaction(function () use ($ids) { |
|
| 339 | + DB::transaction(function() use ($ids) { |
|
| 340 | 340 | $this->model->setNewOrder($ids); |
| 341 | 341 | }, 3); |
| 342 | 342 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public function delete($id) |
| 349 | 349 | { |
| 350 | - return DB::transaction(function () use ($id) { |
|
| 350 | + return DB::transaction(function() use ($id) { |
|
| 351 | 351 | if (($object = $this->model->find($id)) === null) { |
| 352 | 352 | return false; |
| 353 | 353 | } |
@@ -367,9 +367,9 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | public function bulkDelete($ids) |
| 369 | 369 | { |
| 370 | - return DB::transaction(function () use ($ids) { |
|
| 370 | + return DB::transaction(function() use ($ids) { |
|
| 371 | 371 | try { |
| 372 | - Collection::make($ids)->each(function ($id) { |
|
| 372 | + Collection::make($ids)->each(function($id) { |
|
| 373 | 373 | $this->delete($id); |
| 374 | 374 | }); |
| 375 | 375 | } catch (\Exception $e) { |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | public function restore($id) |
| 389 | 389 | { |
| 390 | - return DB::transaction(function () use ($id) { |
|
| 390 | + return DB::transaction(function() use ($id) { |
|
| 391 | 391 | if (($object = $this->model->withTrashed()->find($id)) != null) { |
| 392 | 392 | $object->restore(); |
| 393 | 393 | $this->afterRestore($object); |
@@ -404,14 +404,14 @@ discard block |
||
| 404 | 404 | */ |
| 405 | 405 | public function bulkRestore($ids) |
| 406 | 406 | { |
| 407 | - return DB::transaction(function () use ($ids) { |
|
| 407 | + return DB::transaction(function() use ($ids) { |
|
| 408 | 408 | try { |
| 409 | 409 | $query = $this->model->withTrashed()->whereIn('id', $ids); |
| 410 | 410 | $objects = $query->get(); |
| 411 | 411 | |
| 412 | 412 | $query->restore(); |
| 413 | 413 | |
| 414 | - $objects->each(function ($object) { |
|
| 414 | + $objects->each(function($object) { |
|
| 415 | 415 | $this->afterRestore($object); |
| 416 | 416 | }); |
| 417 | 417 | } catch (\Exception $e) { |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | { |
| 709 | 709 | if (isset($scopes[$scopeField])) { |
| 710 | 710 | $id = $scopes[$scopeField]; |
| 711 | - $query->whereHas($scopeRelation, function ($query) use ($id, $scopeField) { |
|
| 711 | + $query->whereHas($scopeRelation, function($query) use ($id, $scopeField) { |
|
| 712 | 712 | $query->where($scopeField, $id); |
| 713 | 713 | }); |
| 714 | 714 | unset($scopes[$scopeField]); |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | { |
| 740 | 740 | |
| 741 | 741 | if (isset($scopes[$scopeField]) && is_string($scopes[$scopeField])) { |
| 742 | - $query->where(function ($query) use (&$scopes, $scopeField, $orFields) { |
|
| 742 | + $query->where(function($query) use (&$scopes, $scopeField, $orFields) { |
|
| 743 | 743 | foreach ($orFields as $field) { |
| 744 | 744 | $query->orWhere($field, $this->getLikeOperator(), '%' . $scopes[$scopeField] . '%'); |
| 745 | 745 | unset($scopes[$field]); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function getFormFieldsForBrowser($object, $relation, $routePrefix = null, $titleKey = 'title', $moduleName = null) |
| 105 | 105 | { |
| 106 | - return $object->$relation->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 106 | + return $object->$relation->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
| 107 | 107 | return [ |
| 108 | 108 | 'id' => $relatedElement->id, |
| 109 | 109 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getFormFieldsForRelatedBrowser($object, $relation) |
| 124 | 124 | { |
| 125 | - return $object->getRelated($relation)->map(function ($relatedElement) { |
|
| 125 | + return $object->getRelated($relation)->map(function($relatedElement) { |
|
| 126 | 126 | return ($relatedElement != null) ? [ |
| 127 | 127 | 'id' => $relatedElement->id, |
| 128 | 128 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | ]) + (classHasTrait($relatedElement, HasMedias::class) ? [ |
| 133 | 133 | 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 134 | 134 | ] : []) : []; |
| 135 | - })->reject(function ($item) { |
|
| 135 | + })->reject(function($item) { |
|
| 136 | 136 | return empty($item); |
| 137 | 137 | })->values()->toArray(); |
| 138 | 138 | } |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | if (Schema::hasTable(config('twill.related_table', 'related'))) { |
| 46 | 46 | $relatedItems = Collection::make(); |
| 47 | 47 | |
| 48 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object, &$relatedItems) { |
|
| 49 | - Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) { |
|
| 48 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object, &$relatedItems) { |
|
| 49 | + Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) { |
|
| 50 | 50 | try { |
| 51 | 51 | $repository = $this->getModelRepository($item['endpointType'] ?? $browserName); |
| 52 | 52 | $relatedItems->push((object) [ |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | if (Schema::hasTable(config('twill.related_table', 'related'))) { |
| 76 | 76 | if (isset($fields['browsers'])) { |
| 77 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) { |
|
| 77 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) { |
|
| 78 | 78 | $object->saveRelated($items, $browserName); |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $blocksFromConfig = $this->config->get('twill.block_editor.' . ($repeater ? 'repeaters' : 'blocks')); |
| 104 | 104 | |
| 105 | - $block['type'] = Collection::make($blocksFromConfig)->search(function ($blockConfig) use ($block) { |
|
| 105 | + $block['type'] = Collection::make($blocksFromConfig)->search(function($blockConfig) use ($block) { |
|
| 106 | 106 | return $blockConfig['component'] === $block['type']; |
| 107 | 107 | }); |
| 108 | 108 | |
| 109 | 109 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
| 110 | 110 | |
| 111 | 111 | if ($block['browsers']) { |
| 112 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
| 112 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
| 113 | 113 | return Collection::make($items)->pluck('id'); |
| 114 | 114 | })->toArray(); |
| 115 | 115 | |