@@ -39,7 +39,7 @@ |
||
39 | 39 | // so the user has a small window of recovery |
40 | 40 | |
41 | 41 | if($model instanceof HasAsset) { |
42 | - $this->detachAsset->detachAll($model); |
|
42 | + $this->detachAsset->detachAll($model); |
|
43 | 43 | } |
44 | 44 | // TODO: soft-delete the context of this model... (=fragments) |
45 | 45 | // Relation::deleteRelationsOf($model->getMorphClass(), $model->id); |
@@ -38,7 +38,7 @@ |
||
38 | 38 | // TODO: schedule for deletion instead of instantly deleting all relations and stuff... |
39 | 39 | // so the user has a small window of recovery |
40 | 40 | |
41 | - if($model instanceof HasAsset) { |
|
41 | + if ($model instanceof HasAsset) { |
|
42 | 42 | $this->detachAsset->detachAll($model); |
43 | 43 | } |
44 | 44 | // TODO: soft-delete the context of this model... (=fragments) |
@@ -44,7 +44,9 @@ |
||
44 | 44 | // Dynamic localized values or standard translated |
45 | 45 | // For standard translations we set value with the colon notation, e.g. title:en |
46 | 46 | Form::foreachTrans(data_get($input, 'trans', []), function($locale, $key, $value) use($field){ |
47 | - if($key !== $field->getColumn()) return; |
|
47 | + if($key !== $field->getColumn()) { |
|
48 | + return; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | if($this->isFieldForDynamicValue($field)) { |
50 | 52 | $this->setDynamic($key, $value, $locale); |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | { |
32 | 32 | [$input, $files] = $this->removeDuplicateFilePayload($input, $files); |
33 | 33 | |
34 | - foreach($fields as $field){ |
|
35 | - if($this->detectCustomSaveMethod($field)) { |
|
34 | + foreach ($fields as $field) { |
|
35 | + if ($this->detectCustomSaveMethod($field)) { |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
39 | - if(!$field->isLocalized()) |
|
39 | + if (!$field->isLocalized()) |
|
40 | 40 | { |
41 | 41 | // Set standard non-localized attribute on the model |
42 | 42 | ($customSetMethod = $this->detectCustomSetMethod($field)) |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | // Dynamic localized values or standard translated |
50 | 50 | // For standard translations we set value with the colon notation, e.g. title:en |
51 | 51 | Form::foreachTrans(data_get($input, 'trans', []), function($locale, $key, $value) use($field){ |
52 | - if($key !== $field->getColumn()) return; |
|
52 | + if ($key !== $field->getColumn()) return; |
|
53 | 53 | |
54 | - if($this->isFieldForDynamicValue($field)) { |
|
54 | + if ($this->isFieldForDynamicValue($field)) { |
|
55 | 55 | $this->setDynamic($key, $value, $locale); |
56 | - } else { |
|
56 | + }else { |
|
57 | 57 | $this->{$field->getColumn().':'.$locale} = $value; |
58 | 58 | } |
59 | 59 | }); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | $this->save(); |
63 | 63 | |
64 | 64 | // Custom save methods |
65 | - foreach($fields as $field){ |
|
66 | - if($customSaveMethod = $this->detectCustomSaveMethod($field)) { |
|
65 | + foreach ($fields as $field) { |
|
66 | + if ($customSaveMethod = $this->detectCustomSaveMethod($field)) { |
|
67 | 67 | $this->$customSaveMethod($field, $input, $files); |
68 | 68 | } |
69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | |
77 | 77 | private function detectCustomSaveMethod(Field $field): ?string |
78 | 78 | { |
79 | - $saveMethodByKey = 'save' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
80 | - $saveMethodByType = 'save' . ucfirst(Str::camel($field->getType()->get())) . 'Fields'; |
|
79 | + $saveMethodByKey = 'save'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
80 | + $saveMethodByType = 'save'.ucfirst(Str::camel($field->getType()->get())).'Fields'; |
|
81 | 81 | |
82 | 82 | foreach ([$saveMethodByKey, $saveMethodByType] as $saveMethod) { |
83 | 83 | if (method_exists($this, $saveMethod)) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | private function detectCustomSetMethod(Field $field): ?string |
92 | 92 | { |
93 | - $methodName = 'set' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
93 | + $methodName = 'set'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
94 | 94 | |
95 | 95 | return (method_exists($this, $methodName)) ? $methodName : null; |
96 | 96 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | $flatInput = Arr::dot($input); |
122 | 122 | $flatFiles = Arr::dot($files); |
123 | 123 | |
124 | - foreach($flatInput as $key => $entry) { |
|
125 | - if($this->isValidFile($entry) && array_key_exists($key, $flatFiles)) { |
|
124 | + foreach ($flatInput as $key => $entry) { |
|
125 | + if ($this->isValidFile($entry) && array_key_exists($key, $flatFiles)) { |
|
126 | 126 | Arr::forget($input, $key); |
127 | 127 | } |
128 | 128 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | public function sanitize(NodeCollection $collection): NodeCollection |
51 | 51 | { |
52 | 52 | if (!$this->includeHidden) { |
53 | - $collection = $collection->shake(function ($node) { |
|
53 | + $collection = $collection->shake(function($node) { |
|
54 | 54 | return !$node->hidden_in_menu && !$node->draft; |
55 | 55 | }); |
56 | 56 | } |
@@ -14,22 +14,22 @@ |
||
14 | 14 | $this->collection = $items; |
15 | 15 | |
16 | 16 | if ($model) { |
17 | - $this->collection = $this->collection->prune(function ($node) use ($model) { |
|
17 | + $this->collection = $this->collection->prune(function($node) use ($model) { |
|
18 | 18 | return !in_array($model->id, $node->pluckAncestors('id')); |
19 | 19 | }); |
20 | 20 | } |
21 | 21 | |
22 | - $menu = $this->collection->mapRecursive(function ($node) { |
|
22 | + $menu = $this->collection->mapRecursive(function($node) { |
|
23 | 23 | $entry = $node->entry(); |
24 | 24 | $label = $entry->label; |
25 | - $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())) . '>' : ''; |
|
25 | + $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())).'>' : ''; |
|
26 | 26 | $entry->label .= $label; |
27 | 27 | |
28 | 28 | return $node->replaceEntry($entry); |
29 | 29 | }); |
30 | 30 | |
31 | 31 | $menuitems = collect(); |
32 | - $menu->flatten()->each(function ($node) use ($menuitems) { |
|
32 | + $menu->flatten()->each(function($node) use ($menuitems) { |
|
33 | 33 | $menuitems[] = [ |
34 | 34 | 'label' => $node->label, |
35 | 35 | 'id' => $node->id, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | if ($item->ofType(MenuItem::TYPE_INTERNAL) && $owner = $item->owner) { |
28 | 28 | if (public_method_exists($owner, 'isArchived') && $owner->isArchived()) { |
29 | 29 | unset($items[$k]); |
30 | - } else { |
|
30 | + }else { |
|
31 | 31 | $item->url = $item->url(); |
32 | 32 | |
33 | 33 | // Extra info on admin page. |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $collection = NodeCollection::fromArray($items); |
51 | 51 | |
52 | - $collection->mapRecursive(function ($node) { |
|
52 | + $collection->mapRecursive(function($node) { |
|
53 | 53 | return $node->replaceEntry((new MenuItem())->entry($node)); |
54 | 54 | }); |
55 | 55 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $model->parent_id = ($request->input('allow_parent') && $request->input('parent_id')) ? $request->input('parent_id') : null; |
26 | 26 | $model->order = $request->input('order', 0); |
27 | 27 | |
28 | - if($request->input('owner_reference')) { |
|
28 | + if ($request->input('owner_reference')) { |
|
29 | 29 | $owner = ModelReference::fromString($request->input('owner_reference')); |
30 | 30 | $model->owner_type = $owner->className(); |
31 | 31 | $model->owner_id = $owner->id(); |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | if (in_array($menu->order, $sequence)) { |
59 | 59 | foreach ($sequence as $id => $order) { |
60 | 60 | if ($order < $menu->order) { |
61 | - } else { |
|
61 | + }else { |
|
62 | 62 | $sequence[$id]++; |
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - $sequence = $sequence + [$menu->id => $menu->order]; |
|
67 | + $sequence = $sequence+[$menu->id => $menu->order]; |
|
68 | 68 | |
69 | 69 | asort($sequence); |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | private function reorder(array $sequence) |
75 | 75 | { |
76 | - array_walk($sequence, function ($order, $id) { |
|
76 | + array_walk($sequence, function($order, $id) { |
|
77 | 77 | MenuItem::withoutGlobalScope(SoftDeletingScope::class) |
78 | 78 | ->where('id', $id) |
79 | 79 | ->update(['order' => $order]); |
@@ -26,7 +26,7 @@ |
||
26 | 26 | $model->parent_id = ($request->input('allow_parent') && $request->input('parent_id')) ? $request->input('parent_id') : null; |
27 | 27 | $model->menu_type = $request->input('menu_type', 'main'); |
28 | 28 | |
29 | - if($request->input('owner_reference')) { |
|
29 | + if ($request->input('owner_reference')) { |
|
30 | 30 | $owner = ModelReference::fromString($request->input('owner_reference')); |
31 | 31 | $model->owner_type = $owner->className(); |
32 | 32 | $model->owner_id = $owner->id(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function url($locale = null) |
72 | 72 | { |
73 | - if(!$locale) $locale = app()->getLocale(); |
|
73 | + if (!$locale) $locale = app()->getLocale(); |
|
74 | 74 | |
75 | 75 | if ($this->ofType(static::TYPE_INTERNAL) && $owner = $this->owner) { |
76 | 76 | return $owner->url($locale); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'id' => $node->id, |
91 | 91 | 'type' => $node->type, |
92 | 92 | 'label' => $node->label, |
93 | - 'page_label' => $node->page_label, // Extra info when dealing with internal links |
|
93 | + 'page_label' => $node->page_label, // Extra info when dealing with internal links |
|
94 | 94 | 'url' => $node->url(), |
95 | 95 | 'order' => $node->order, |
96 | 96 | 'owner_type' => $node->owner_type, |
@@ -70,7 +70,9 @@ |
||
70 | 70 | |
71 | 71 | public function url($locale = null) |
72 | 72 | { |
73 | - if(!$locale) $locale = app()->getLocale(); |
|
73 | + if(!$locale) { |
|
74 | + $locale = app()->getLocale(); |
|
75 | + } |
|
74 | 76 | |
75 | 77 | if ($this->ofType(static::TYPE_INTERNAL) && $owner = $this->owner) { |
76 | 78 | return $owner->url($locale); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | return $value; |
13 | 13 | } |
14 | 14 | |
15 | - $value = preg_replace_callback(static::$pattern, function ($matches) { |
|
15 | + $value = preg_replace_callback(static::$pattern, function($matches) { |
|
16 | 16 | |
17 | 17 | // First entry of matches contains our full captured group, which we want to replace. |
18 | 18 | // Second entry is the text itself, without the brackets |