@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
56 | - if (method_exists(get_called_class(), $method = 'getCountByStatusSlug'.class_basename($trait))) { |
|
56 | + if (method_exists(get_called_class(), $method = 'getCountByStatusSlug' . class_basename($trait))) { |
|
57 | 57 | if ($count = $this->$method($slug)) { |
58 | 58 | return $count; |
59 | 59 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $query = $this->model->newQuery(); |
94 | 94 | |
95 | 95 | if ($exceptId) { |
96 | - $query = $query->where($this->model->getTable().'.id', '<>', $exceptId); |
|
96 | + $query = $query->where($this->model->getTable() . '.id', '<>', $exceptId); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if ($this->model instanceof Sortable) { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function create($fields) |
118 | 118 | { |
119 | - return DB::transaction(function () use ($fields) { |
|
119 | + return DB::transaction(function() use ($fields) { |
|
120 | 120 | $original_fields = $fields; |
121 | 121 | |
122 | 122 | $fields = $this->prepareFieldsBeforeCreate($fields); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | public function update($id, $fields) |
148 | 148 | { |
149 | - DB::transaction(function () use ($id, $fields) { |
|
149 | + DB::transaction(function() use ($id, $fields) { |
|
150 | 150 | $object = $this->model->findOrFail($id); |
151 | 151 | |
152 | 152 | $this->beforeSave($object, $fields); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | public function updateBasic($id, $values, $scopes = []) |
165 | 165 | { |
166 | - return DB::transaction(function () use ($id, $values, $scopes) { |
|
166 | + return DB::transaction(function() use ($id, $values, $scopes) { |
|
167 | 167 | // apply scopes if no id provided |
168 | 168 | if (is_null($id)) { |
169 | 169 | $query = $this->model->query(); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | $query->update($values); |
176 | 176 | |
177 | - $query->get()->each(function ($object) use ($values) { |
|
177 | + $query->get()->each(function($object) use ($values) { |
|
178 | 178 | $this->afterUpdateBasic($object, $values); |
179 | 179 | }); |
180 | 180 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $query = $this->model->whereIn('id', $id); |
187 | 187 | $query->update($values); |
188 | 188 | |
189 | - $query->get()->each(function ($object) use ($values) { |
|
189 | + $query->get()->each(function($object) use ($values) { |
|
190 | 190 | $this->afterUpdateBasic($object, $values); |
191 | 191 | }); |
192 | 192 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | |
207 | 207 | public function setNewOrder($ids) |
208 | 208 | { |
209 | - DB::transaction(function () use ($ids) { |
|
209 | + DB::transaction(function() use ($ids) { |
|
210 | 210 | $this->model->setNewOrder($ids); |
211 | 211 | }, 3); |
212 | 212 | } |
213 | 213 | |
214 | 214 | public function delete($id) |
215 | 215 | { |
216 | - return DB::transaction(function () use ($id) { |
|
216 | + return DB::transaction(function() use ($id) { |
|
217 | 217 | if (($object = $this->model->find($id)) != null) { |
218 | 218 | $object->delete(); |
219 | 219 | $this->afterDelete($object); |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | |
228 | 228 | public function bulkDelete($ids) |
229 | 229 | { |
230 | - return DB::transaction(function () use ($ids) { |
|
230 | + return DB::transaction(function() use ($ids) { |
|
231 | 231 | try { |
232 | 232 | $query = $this->model->whereIn('id', $ids); |
233 | 233 | $objects = $query->get(); |
234 | 234 | |
235 | 235 | $query->delete(); |
236 | 236 | |
237 | - $objects->each(function ($object) { |
|
237 | + $objects->each(function($object) { |
|
238 | 238 | $this->afterDelete($object); |
239 | 239 | }); |
240 | 240 | } catch (\Exception $e) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | public function restore($id) |
251 | 251 | { |
252 | - return DB::transaction(function () use ($id) { |
|
252 | + return DB::transaction(function() use ($id) { |
|
253 | 253 | if (($object = $this->model->withTrashed()->find($id)) != null) { |
254 | 254 | $object->restore(); |
255 | 255 | $this->afterRestore($object); |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | |
264 | 264 | public function bulkRestore($ids) |
265 | 265 | { |
266 | - return DB::transaction(function () use ($ids) { |
|
266 | + return DB::transaction(function() use ($ids) { |
|
267 | 267 | try { |
268 | 268 | $query = $this->model->withTrashed()->whereIn('id', $ids); |
269 | 269 | $objects = $query->get(); |
270 | 270 | |
271 | 271 | $query->restore(); |
272 | 272 | |
273 | - $objects->each(function ($object) { |
|
273 | + $objects->each(function($object) { |
|
274 | 274 | $this->afterRestore($object); |
275 | 275 | }); |
276 | 276 | } catch (\Exception $e) { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $fields = $this->cleanupFields(null, $fields); |
325 | 325 | |
326 | 326 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
327 | - if (method_exists(get_called_class(), $method = 'prepareFieldsBeforeCreate'.class_basename($trait))) { |
|
327 | + if (method_exists(get_called_class(), $method = 'prepareFieldsBeforeCreate' . class_basename($trait))) { |
|
328 | 328 | $fields = $this->$method($fields); |
329 | 329 | } |
330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $fields = $this->cleanupFields($object, $fields); |
338 | 338 | |
339 | 339 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
340 | - if (method_exists(get_called_class(), $method = 'prepareFieldsBeforeSave'.class_basename($trait))) { |
|
340 | + if (method_exists(get_called_class(), $method = 'prepareFieldsBeforeSave' . class_basename($trait))) { |
|
341 | 341 | $fields = $this->$method($object, $fields); |
342 | 342 | } |
343 | 343 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | public function afterUpdateBasic($object, $fields) |
349 | 349 | { |
350 | 350 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
351 | - if (method_exists(get_called_class(), $method = 'afterUpdateBasic'.class_basename($trait))) { |
|
351 | + if (method_exists(get_called_class(), $method = 'afterUpdateBasic' . class_basename($trait))) { |
|
352 | 352 | $this->$method($object, $fields); |
353 | 353 | } |
354 | 354 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function beforeSave($object, $fields) |
358 | 358 | { |
359 | 359 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
360 | - if (method_exists(get_called_class(), $method = 'beforeSave'.class_basename($trait))) { |
|
360 | + if (method_exists(get_called_class(), $method = 'beforeSave' . class_basename($trait))) { |
|
361 | 361 | $this->$method($object, $fields); |
362 | 362 | } |
363 | 363 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | public function afterSave($object, $fields) |
367 | 367 | { |
368 | 368 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
369 | - if (method_exists(get_called_class(), $method = 'afterSave'.class_basename($trait))) { |
|
369 | + if (method_exists(get_called_class(), $method = 'afterSave' . class_basename($trait))) { |
|
370 | 370 | $this->$method($object, $fields); |
371 | 371 | } |
372 | 372 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | public function afterDelete($object) |
376 | 376 | { |
377 | 377 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
378 | - if (method_exists(get_called_class(), $method = 'afterDelete'.class_basename($trait))) { |
|
378 | + if (method_exists(get_called_class(), $method = 'afterDelete' . class_basename($trait))) { |
|
379 | 379 | $this->$method($object); |
380 | 380 | } |
381 | 381 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | public function afterRestore($object) |
385 | 385 | { |
386 | 386 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
387 | - if (method_exists(get_called_class(), $method = 'afterRestore'.class_basename($trait))) { |
|
387 | + if (method_exists(get_called_class(), $method = 'afterRestore' . class_basename($trait))) { |
|
388 | 388 | $this->$method($object); |
389 | 389 | } |
390 | 390 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | public function hydrate($object, $fields) |
394 | 394 | { |
395 | 395 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
396 | - if (method_exists(get_called_class(), $method = 'hydrate'.class_basename($trait))) { |
|
396 | + if (method_exists(get_called_class(), $method = 'hydrate' . class_basename($trait))) { |
|
397 | 397 | $object = $this->$method($object, $fields); |
398 | 398 | } |
399 | 399 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $fields = $object->attributesToArray(); |
407 | 407 | |
408 | 408 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
409 | - if (method_exists(get_called_class(), $method = 'getFormFields'.class_basename($trait))) { |
|
409 | + if (method_exists(get_called_class(), $method = 'getFormFields' . class_basename($trait))) { |
|
410 | 410 | $fields = $this->$method($object, $fields); |
411 | 411 | } |
412 | 412 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $likeOperator = $this->getLikeOperator(); |
420 | 420 | |
421 | 421 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
422 | - if (method_exists(get_called_class(), $method = 'filter'.class_basename($trait))) { |
|
422 | + if (method_exists(get_called_class(), $method = 'filter' . class_basename($trait))) { |
|
423 | 423 | $this->$method($query, $scopes); |
424 | 424 | } |
425 | 425 | } |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | unset($scopes['search']); |
428 | 428 | |
429 | 429 | if (isset($scopes['exceptIds'])) { |
430 | - $query->whereNotIn($this->model->getTable().'.id', $scopes['exceptIds']); |
|
430 | + $query->whereNotIn($this->model->getTable() . '.id', $scopes['exceptIds']); |
|
431 | 431 | unset($scopes['exceptIds']); |
432 | 432 | } |
433 | 433 | |
434 | 434 | foreach ($scopes as $column => $value) { |
435 | - if (method_exists($this->model, 'scope'.ucfirst($column))) { |
|
435 | + if (method_exists($this->model, 'scope' . ucfirst($column))) { |
|
436 | 436 | $query->$column(); |
437 | 437 | } else { |
438 | 438 | if (is_array($value)) { |
439 | 439 | $query->whereIn($column, $value); |
440 | 440 | } elseif ($column[0] == '%') { |
441 | - $value && ($value[0] == '!') ? $query->where(substr($column, 1), "not $likeOperator", '%'.substr($value, 1).'%') : $query->where(substr($column, 1), $likeOperator, '%'.$value.'%'); |
|
441 | + $value && ($value[0] == '!') ? $query->where(substr($column, 1), "not $likeOperator", '%' . substr($value, 1) . '%') : $query->where(substr($column, 1), $likeOperator, '%' . $value . '%'); |
|
442 | 442 | } elseif (isset($value[0]) && $value[0] == '!') { |
443 | 443 | $query->where($column, '<>', substr($value, 1)); |
444 | 444 | } elseif ($value !== '') { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | foreach (class_uses_recursive(get_called_class()) as $trait) { |
460 | - if (method_exists(get_called_class(), $method = 'order'.class_basename($trait))) { |
|
460 | + if (method_exists(get_called_class(), $method = 'order' . class_basename($trait))) { |
|
461 | 461 | $this->$method($query, $orders); |
462 | 462 | } |
463 | 463 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | |
468 | 468 | public function getFormFieldsForBrowser($object, $relation, $routePrefix = null, $titleKey = 'title', $moduleName = null) |
469 | 469 | { |
470 | - return $object->$relation->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
470 | + return $object->$relation->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
471 | 471 | return [ |
472 | 472 | 'id' => $relatedElement->id, |
473 | 473 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | { |
523 | 523 | if (isset($scopes[$scopeField])) { |
524 | 524 | $id = $scopes[$scopeField]; |
525 | - $query->whereHas($scopeRelation, function ($query) use ($id, $scopeField) { |
|
525 | + $query->whereHas($scopeRelation, function($query) use ($id, $scopeField) { |
|
526 | 526 | $query->where($scopeField, $id); |
527 | 527 | }); |
528 | 528 | unset($scopes[$scopeField]); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | public function addLikeFilterScope($query, &$scopes, $scopeField) |
533 | 533 | { |
534 | 534 | if (isset($scopes[$scopeField]) && is_string($scopes[$scopeField])) { |
535 | - $query->where($scopeField, $this->getLikeOperator(), '%'.$scopes[$scopeField].'%'); |
|
535 | + $query->where($scopeField, $this->getLikeOperator(), '%' . $scopes[$scopeField] . '%'); |
|
536 | 536 | unset($scopes[$scopeField]); |
537 | 537 | } |
538 | 538 | } |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | public function searchIn($query, &$scopes, $scopeField, $orFields = []) |
541 | 541 | { |
542 | 542 | if (isset($scopes[$scopeField]) && is_string($scopes[$scopeField])) { |
543 | - $query->where(function ($query) use (&$scopes, $scopeField, $orFields) { |
|
543 | + $query->where(function($query) use (&$scopes, $scopeField, $orFields) { |
|
544 | 544 | foreach ($orFields as $field) { |
545 | - $query->orWhere($field, $this->getLikeOperator(), '%'.$scopes[$scopeField].'%'); |
|
545 | + $query->orWhere($field, $this->getLikeOperator(), '%' . $scopes[$scopeField] . '%'); |
|
546 | 546 | unset($scopes[$field]); |
547 | 547 | } |
548 | 548 | }); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $model = ucfirst(str_singular($relation)); |
583 | 583 | } |
584 | 584 | |
585 | - return app(config('twill.namespace').'\\Repositories\\'.ucfirst($model).'Repository'); |
|
585 | + return app(config('twill.namespace') . '\\Repositories\\' . ucfirst($model) . 'Repository'); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | private function getLikeOperator() |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | |
21 | 21 | $submittedLanguages = collect($fields['languages'] ?? []); |
22 | 22 | |
23 | - $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) { |
|
23 | + $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) { |
|
24 | 24 | return $language['published']; |
25 | 25 | }); |
26 | 26 | |
27 | 27 | foreach ($locales as $index => $locale) { |
28 | - $submittedLanguage = array_first($submittedLanguages->filter(function ($lang) use ($locale) { |
|
28 | + $submittedLanguage = array_first($submittedLanguages->filter(function($lang) use ($locale) { |
|
29 | 29 | return $lang['value'] == $locale; |
30 | 30 | })); |
31 | 31 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $fields[$locale] = [ |
37 | 37 | 'active' => $activeField, |
38 | - ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
38 | + ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
39 | 39 | $attributeValue = $fields[$attribute] ?? null; |
40 | 40 | |
41 | 41 | // if we are at the last locale, |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | { |
77 | 77 | if (property_exists($this->model, 'translatedAttributes')) { |
78 | 78 | $attributes = $this->model->translatedAttributes; |
79 | - $query->whereHas('translations', function ($q) use ($scopes, $attributes) { |
|
79 | + $query->whereHas('translations', function($q) use ($scopes, $attributes) { |
|
80 | 80 | foreach ($attributes as $attribute) { |
81 | 81 | if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) { |
82 | - $q->where($attribute, 'like', '%'.$scopes[$attribute].'%'); |
|
82 | + $q->where($attribute, 'like', '%' . $scopes[$attribute] . '%'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | }); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $isOrdered = false; |
105 | 105 | foreach ($attributes as $attribute) { |
106 | 106 | if (isset($orders[$attribute])) { |
107 | - $query->orderBy($tableTranslation.'.'.$attribute, $orders[$attribute]); |
|
107 | + $query->orderBy($tableTranslation . '.' . $attribute, $orders[$attribute]); |
|
108 | 108 | $isOrdered = true; |
109 | 109 | unset($orders[$attribute]); |
110 | 110 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | if ($isOrdered) { |
114 | 114 | $query |
115 | - ->join($tableTranslation, $foreignKey, '=', $table.'.id') |
|
116 | - ->where($tableTranslation.'.locale', '=', $orders['locale'] ?? app()->getLocale()) |
|
117 | - ->select($table.'.*'); |
|
115 | + ->join($tableTranslation, $foreignKey, '=', $table . '.id') |
|
116 | + ->where($tableTranslation . '.locale', '=', $orders['locale'] ?? app()->getLocale()) |
|
117 | + ->select($table . '.*'); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $relationRepository = $this->getModelRepository($relation, $model); |
13 | 13 | |
14 | 14 | if (!$keepExisting) { |
15 | - $object->$relation()->each(function ($repeaterElement) { |
|
15 | + $object->$relation()->each(function($repeaterElement) { |
|
16 | 16 | $repeaterElement->forceDelete(); |
17 | 17 | }); |
18 | 18 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $relationField['position'] = $index + 1; |
46 | 46 | if (isset($relationField['id']) && starts_with($relationField['id'], $relation)) { |
47 | 47 | // row already exists, let's update |
48 | - $id = str_replace($relation.'-', '', $relationField['id']); |
|
48 | + $id = str_replace($relation . '-', '', $relationField['id']); |
|
49 | 49 | $relationRepository->update($id, $relationField); |
50 | 50 | $currentIdList[] = $id; |
51 | 51 | } else { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | foreach ($object->$relation as $relationItem) { |
81 | 81 | $repeaters[] = [ |
82 | - 'id' => $relation.'-'.$relationItem->id, |
|
82 | + 'id' => $relation . '-' . $relationItem->id, |
|
83 | 83 | 'type' => $repeatersConfig[$relation]['component'], |
84 | 84 | 'title' => $repeatersConfig[$relation]['title'], |
85 | 85 | ]; |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | if (isset($relatedItemFormFields['files'])) { |
108 | 108 | $repeatersFiles = []; |
109 | 109 | |
110 | - collect($relatedItemFormFields['files'])->each(function ($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
111 | - $repeatersFiles[] = collect($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $relation, $relationItem) { |
|
110 | + collect($relatedItemFormFields['files'])->each(function($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
111 | + $repeatersFiles[] = collect($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $relation, $relationItem) { |
|
112 | 112 | return [ |
113 | 113 | "blocks[$relation-$relationItem->id][$role][$locale]" => $files, |
114 | 114 | ]; |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | $blocksFromFields = $this->getBlocks($object, $fields); |
18 | 18 | $blockRepository = app(BlockRepository::class); |
19 | 19 | |
20 | - $blocksFromFields->each(function ($block, $key) use ($blocksCollection, $blockRepository) { |
|
20 | + $blocksFromFields->each(function($block, $key) use ($blocksCollection, $blockRepository) { |
|
21 | 21 | $newBlock = $blockRepository->createForPreview($block); |
22 | 22 | $newBlock->id = $key + 1; |
23 | 23 | |
24 | 24 | $blocksCollection->push($newBlock); |
25 | 25 | |
26 | - $block['blocks']->each(function ($childBlock) use ($newBlock, $blocksCollection, $blockRepository) { |
|
26 | + $block['blocks']->each(function($childBlock) use ($newBlock, $blocksCollection, $blockRepository) { |
|
27 | 27 | $childBlock['parent_id'] = $newBlock->id; |
28 | 28 | $newChildBlock = $blockRepository->createForPreview($childBlock); |
29 | 29 | $blocksCollection->push($newChildBlock); |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
47 | 47 | |
48 | - $this->getBlocks($object, $fields)->each(function ($block) use ($object, $blockRepository) { |
|
48 | + $this->getBlocks($object, $fields)->each(function($block) use ($object, $blockRepository) { |
|
49 | 49 | $blockCreated = $blockRepository->create($block); |
50 | 50 | |
51 | - $block['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
51 | + $block['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
52 | 52 | $childBlock['parent_id'] = $blockCreated->id; |
53 | 53 | $blockRepository->create($childBlock); |
54 | 54 | }); |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | ]; |
128 | 128 | } |
129 | 129 | |
130 | - $fields['blocksFields'][] = collect($block['content'])->filter(function ($value, $key) { |
|
130 | + $fields['blocksFields'][] = collect($block['content'])->filter(function($value, $key) { |
|
131 | 131 | return $key !== 'browsers'; |
132 | - })->map(function ($value, $key) use ($block) { |
|
132 | + })->map(function($value, $key) use ($block) { |
|
133 | 133 | return [ |
134 | 134 | 'name' => "blocks[$block->id][$key]", |
135 | 135 | 'value' => $value, |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $medias = $blockFormFields['medias']; |
142 | 142 | |
143 | 143 | if ($medias) { |
144 | - $fields['blocksMedias'][] = collect($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
144 | + $fields['blocksMedias'][] = collect($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
145 | 145 | return [ |
146 | 146 | "blocks[$block->id][$key]" => $value, |
147 | 147 | ]; |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $files = $blockFormFields['files']; |
152 | 152 | |
153 | 153 | if ($files) { |
154 | - collect($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
155 | - $fields['blocksFiles'][] = collect($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
154 | + collect($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
155 | + $fields['blocksFiles'][] = collect($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
156 | 156 | return [ |
157 | 157 | "blocks[$block->id][$role][$locale]" => $files, |
158 | 158 | ]; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | protected function getBlockBrowsers($block) |
189 | 189 | { |
190 | - return collect($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
190 | + return collect($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
191 | 191 | $relationRepository = $this->getModelRepository($relation); |
192 | 192 | $relatedItems = $relationRepository->get([], ['id' => $ids], [], -1); |
193 | 193 | $sortedRelatedItems = array_flip($ids); |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | $sortedRelatedItems[$item->id] = $item; |
197 | 197 | } |
198 | 198 | |
199 | - $items = collect(array_values($sortedRelatedItems))->filter(function ($value) { |
|
199 | + $items = collect(array_values($sortedRelatedItems))->filter(function($value) { |
|
200 | 200 | return is_object($value); |
201 | - })->map(function ($relatedElement) use ($relation) { |
|
201 | + })->map(function($relatedElement) use ($relation) { |
|
202 | 202 | return [ |
203 | 203 | 'id' => $relatedElement->id, |
204 | 204 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
205 | - 'edit' => moduleRoute($relation, config('twill.block_editor.browser_route_prefixes.'.$relation), 'edit', $relatedElement->id), |
|
205 | + 'edit' => moduleRoute($relation, config('twill.block_editor.browser_route_prefixes.' . $relation), 'edit', $relatedElement->id), |
|
206 | 206 | ] + (classHasTrait($relatedElement, HasMedias::class) ? [ |
207 | 207 | 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]), |
208 | 208 | ] : []); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $filesCollection = collect(); |
16 | 16 | $filesFromFields = $this->getFiles($fields); |
17 | 17 | |
18 | - $filesFromFields->each(function ($file) use ($object, $filesCollection) { |
|
18 | + $filesFromFields->each(function($file) use ($object, $filesCollection) { |
|
19 | 19 | $newFile = File::withTrashed()->find($file['id']); |
20 | 20 | $pivot = $newFile->newPivot($object, array_except($file, ['id']), 'fileables', true); |
21 | 21 | $newFile->setRelation('pivot', $pivot); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $object->files()->sync([]); |
37 | 37 | |
38 | - $this->getFiles($fields)->each(function ($file) use ($object) { |
|
38 | + $this->getFiles($fields)->each(function($file) use ($object) { |
|
39 | 39 | $object->files()->attach($file['id'], array_except($file, ['id'])); |
40 | 40 | }); |
41 | 41 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $locale = $locale ?? config('app.locale'); |
57 | 57 | if (in_array($role, $this->model->filesParams ?? []) |
58 | 58 | || in_array($role, config('twill.block_editor.files', []))) { |
59 | - collect($filesForRole)->each(function ($file) use (&$files, $role, $locale) { |
|
59 | + collect($filesForRole)->each(function($file) use (&$files, $role, $locale) { |
|
60 | 60 | $files->push([ |
61 | 61 | 'id' => $file['id'], |
62 | 62 | 'role' => $role, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ($object->has('files')) { |
78 | 78 | foreach ($object->files->groupBy('pivot.role') as $role => $filesByRole) { |
79 | 79 | foreach ($filesByRole->groupBy('pivot.locale') as $locale => $filesByLocale) { |
80 | - $fields['files'][$locale][$role] = $filesByRole->map(function ($file) { |
|
80 | + $fields['files'][$locale][$role] = $filesByRole->map(function($file) { |
|
81 | 81 | return $file->toCmsArray(); |
82 | 82 | }); |
83 | 83 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | $tagQuery = $this->getTagsQuery(); |
41 | 41 | |
42 | 42 | if (!empty($query)) { |
43 | - $tagQuery->where('slug', 'like', '%'.$query.'%'); |
|
43 | + $tagQuery->where('slug', 'like', '%' . $query . '%'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | if (!empty($ids)) { |
47 | 47 | foreach ($ids as $id) { |
48 | - $tagQuery->whereHas('tagged', function ($query) use ($id) { |
|
48 | + $tagQuery->whereHas('tagged', function($query) use ($id) { |
|
49 | 49 | $query->where('taggable_id', $id); |
50 | 50 | }); |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function getTagsList() |
58 | 58 | { |
59 | - return $this->getTagsQuery()->where('count', '>', 0)->select('name', 'id')->get()->map(function ($tag) { |
|
59 | + return $this->getTagsQuery()->where('count', '>', 0)->select('name', 'id')->get()->map(function($tag) { |
|
60 | 60 | return [ |
61 | 61 | 'label' => $tag->name, |
62 | 62 | 'value' => $tag->id, |
@@ -13,16 +13,16 @@ discard block |
||
13 | 13 | |
14 | 14 | public function byKey($key, $section = null) |
15 | 15 | { |
16 | - return $this->model->when($section, function ($query) use ($section) { |
|
16 | + return $this->model->when($section, function($query) use ($section) { |
|
17 | 17 | $query->where('section', $section); |
18 | 18 | })->where('key', $key)->exists() ? $this->model->where('key', $key)->with('translations')->first()->value : null; |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function getFormFields($section = null) |
22 | 22 | { |
23 | - return $this->model->when($section, function ($query) use ($section) { |
|
23 | + return $this->model->when($section, function($query) use ($section) { |
|
24 | 24 | $query->where('section', $section); |
25 | - })->with('translations')->get()->mapWithKeys(function ($setting) { |
|
25 | + })->with('translations')->get()->mapWithKeys(function($setting) { |
|
26 | 26 | $settingValue = []; |
27 | 27 | foreach ($setting->translations as $translation) { |
28 | 28 | $settingValue[$translation->locale] = $translation->value; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | foreach (getLocales() as $locale) { |
41 | 41 | array_set( |
42 | 42 | $settingsTranslated, |
43 | - $key.'.'.$locale, |
|
43 | + $key . '.' . $locale, |
|
44 | 44 | ['value' => $value[$locale]] + ['active' => true] |
45 | 45 | ); |
46 | 46 | } |
@@ -28,16 +28,16 @@ |
||
28 | 28 | |
29 | 29 | public function buildFromCmsArray($block, $repeater = false) |
30 | 30 | { |
31 | - $blocksFromConfig = config('twill.block_editor.'.($repeater ? 'repeaters' : 'blocks')); |
|
31 | + $blocksFromConfig = config('twill.block_editor.' . ($repeater ? 'repeaters' : 'blocks')); |
|
32 | 32 | |
33 | - $block['type'] = collect($blocksFromConfig)->search(function ($blockConfig) use ($block) { |
|
33 | + $block['type'] = collect($blocksFromConfig)->search(function($blockConfig) use ($block) { |
|
34 | 34 | return $blockConfig['component'] === $block['type']; |
35 | 35 | }); |
36 | 36 | |
37 | 37 | $block['content'] = empty($block['content']) ? new \stdClass() : (object) $block['content']; |
38 | 38 | |
39 | 39 | if ($block['browsers']) { |
40 | - $browsers = collect($block['browsers'])->map(function ($items) { |
|
40 | + $browsers = collect($block['browsers'])->map(function($items) { |
|
41 | 41 | return collect($items)->pluck('id'); |
42 | 42 | })->toArray(); |
43 | 43 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | public function getDimensionsAttribute() |
24 | 24 | { |
25 | - return $this->width.'x'.$this->height; |
|
25 | + return $this->width . 'x' . $this->height; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function altTextFrom($filename) |