@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | public static function modelsByType(array $types, Model $ignoredModel = null, bool $online = true) |
91 | 91 | { |
92 | - $models = chiefMemoize('all-online-models-' . implode('_', $types), function () use ($types, $online) { |
|
92 | + $models = chiefMemoize('all-online-models-'.implode('_', $types), function() use ($types, $online) { |
|
93 | 93 | $builder = UrlRecord::whereNull('redirect_id') |
94 | 94 | ->select('model_type', 'model_id') |
95 | 95 | ->groupBy('model_type', 'model_id'); |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $builder->whereIn('model_type', $types); |
99 | 99 | } |
100 | 100 | |
101 | - return $builder->get()->mapToGroups(function ($record) { |
|
101 | + return $builder->get()->mapToGroups(function($record) { |
|
102 | 102 | return [$record->model_type => $record->model_id]; |
103 | - })->map(function ($record, $key) { |
|
103 | + })->map(function($record, $key) { |
|
104 | 104 | return Morphables::instance($key)->find($record->toArray()); |
105 | - })->map->reject(function ($model) use ($online) { |
|
105 | + })->map->reject(function($model) use ($online) { |
|
106 | 106 | if ($online) { |
107 | 107 | return is_null($model) || (public_method_exists($model, 'isPublished') && !$model->isPublished()); |
108 | 108 | } // Invalid references to archived or removed models where url record still exists. |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | }); |
113 | 113 | |
114 | 114 | if ($ignoredModel) { |
115 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
115 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
116 | 116 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
117 | 117 | }); |
118 | 118 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | return $filename; |
141 | 141 | } |
142 | 142 | |
143 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
143 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
144 | 144 | $filename = substr($filename, 0, strrpos($filename, '.')); |
145 | 145 | |
146 | - return Str::slug($filename) . '.' . $extension; |
|
146 | + return Str::slug($filename).'.'.$extension; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function sort(HasAsset $model, MediaField $field, array $input) |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $values = isset($fileIdInput[$key]) |
170 | 170 | ? $fileIdInput[$key] |
171 | 171 | : ( |
172 | - isset($fileIdInput['files-' . $key]) |
|
173 | - ? $fileIdInput['files-' . $key] |
|
172 | + isset($fileIdInput['files-'.$key]) |
|
173 | + ? $fileIdInput['files-'.$key] |
|
174 | 174 | : '' |
175 | 175 | ); |
176 | 176 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | public function handle(HasAsset $model, MediaField $field, array $input, array $files): void |
16 | 16 | { |
17 | - foreach ([data_get($files, 'files.' . $field->getName(), []), data_get($input, 'files.' . $field->getName(), [])] as $requestPayload) { |
|
17 | + foreach ([data_get($files, 'files.'.$field->getName(), []), data_get($input, 'files.'.$field->getName(), [])] as $requestPayload) { |
|
18 | 18 | foreach ($requestPayload as $locale => $values) { |
19 | 19 | $this->handlePayload($model, $field, $locale, $values); |
20 | 20 | } |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | // TODO: how to assign for pagebuilder?? with tag, via the chief relations config or is this default |
37 | 37 | $moduleManagerClasses = $this->registeredManagers->tagged('module')->get(); |
38 | 38 | |
39 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
39 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
40 | 40 | return app($moduleManagerClass); |
41 | 41 | }, $moduleManagerClasses)); |
42 | 42 | |
43 | 43 | return $managers |
44 | - ->reject(function($manager){ return !$manager->can('create'); }) |
|
44 | + ->reject(function($manager) { return !$manager->can('create'); }) |
|
45 | 45 | ->map(function($manager) use($ownerType, $ownerId){ |
46 | 46 | return [ |
47 | 47 | 'label' => $manager->adminLabel('page_title'), |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | // Get the modules that are set to be shareable. |
57 | 57 | $moduleManagerClasses = $this->shareableModules(); |
58 | 58 | |
59 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
59 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
60 | 60 | return app($moduleManagerClass); |
61 | 61 | }, $moduleManagerClasses)); |
62 | 62 | |
63 | 63 | return $managers |
64 | - ->reject(function($manager){ return !$manager->can('create-shared'); }) |
|
65 | - ->map(function($manager){ |
|
64 | + ->reject(function($manager) { return !$manager->can('create-shared'); }) |
|
65 | + ->map(function($manager) { |
|
66 | 66 | return [ |
67 | 67 | 'label' => $manager->adminLabel('page_title'), |
68 | 68 | 'value' => $manager->route('create-shared') |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $model->saveFields($model->fields()->tagged('create'), $request->all(), $request->allFiles()); |
92 | 92 | |
93 | 93 | return redirect()->to($this->route('edit', $model)) |
94 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
94 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function edit($id) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | return view('chief::back.managers.edit', [ |
107 | 107 | 'model' => $model, |
108 | 108 | 'managerViewModel' => $this->managerViewModel(), |
109 | - 'fields' => $model->fields()->map(function (Field $field) use ($model) { |
|
109 | + 'fields' => $model->fields()->map(function(Field $field) use ($model) { |
|
110 | 110 | // TODO refactor so render method of field takes model and managerViewModel as arguments. |
111 | 111 | return $field->model($model) |
112 | 112 | ->viewData(['managerViewModel' => $this->managerViewModel()]); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $model->saveFields($model->fields(), $request->all(), $request->allFiles()); |
127 | 127 | |
128 | 128 | return redirect()->to($this->route('edit', $model)) |
129 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is aangepast'); |
|
129 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is aangepast'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function delete($id, Request $request) |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | $model = static::managedModelClass()::findOrFail($id); |
137 | 137 | |
138 | 138 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
139 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
139 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | app(DeleteManagedModel::class)->handle($model); |
143 | 143 | |
144 | 144 | return redirect()->to($this->route('index')) |
145 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
145 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
146 | 146 | } |
147 | 147 | } |
@@ -159,7 +159,7 @@ |
||
159 | 159 | if (is_array_empty($translation)) { |
160 | 160 | |
161 | 161 | // Nullify all values |
162 | - $trans[$locale] = array_map(function ($value) { |
|
162 | + $trans[$locale] = array_map(function($value) { |
|
163 | 163 | return null; |
164 | 164 | }, $translation); |
165 | 165 | continue; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | public function find(string $key): Field |
42 | 42 | { |
43 | - if(!isset($this->fields[$key])) { |
|
44 | - throw new \InvalidArgumentException('No field found by key ' . $key); |
|
43 | + if (!isset($this->fields[$key])) { |
|
44 | + throw new \InvalidArgumentException('No field found by key '.$key); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $this->fields[$key]; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | continue; |
102 | 102 | } |
103 | 103 | |
104 | - $method = 'get' . ucfirst($key); |
|
104 | + $method = 'get'.ucfirst($key); |
|
105 | 105 | |
106 | 106 | // Reject from list if value does not match expected one |
107 | 107 | if ($value && $value == $field->$method()) { |
@@ -117,30 +117,30 @@ discard block |
||
117 | 117 | |
118 | 118 | public function render(): string |
119 | 119 | { |
120 | - return array_reduce($this->fields, function (string $carry, Field $field) { |
|
121 | - return $carry . $field->render(); |
|
120 | + return array_reduce($this->fields, function(string $carry, Field $field) { |
|
121 | + return $carry.$field->render(); |
|
122 | 122 | }, ''); |
123 | 123 | } |
124 | 124 | |
125 | 125 | public function keyed($key): Fields |
126 | 126 | { |
127 | - $keys = (array) $key; |
|
127 | + $keys = (array)$key; |
|
128 | 128 | |
129 | - return new static(array_filter($this->fields, function (Field $field) use ($keys) { |
|
129 | + return new static(array_filter($this->fields, function(Field $field) use ($keys) { |
|
130 | 130 | return in_array($field->getKey(), $keys); |
131 | 131 | })); |
132 | 132 | } |
133 | 133 | |
134 | 134 | public function tagged($tag): Fields |
135 | 135 | { |
136 | - return new static(array_filter($this->fields, function (Field $field) use ($tag) { |
|
136 | + return new static(array_filter($this->fields, function(Field $field) use ($tag) { |
|
137 | 137 | return $field->tagged($tag); |
138 | 138 | })); |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function untagged(): Fields |
142 | 142 | { |
143 | - return new static(array_filter($this->fields, function (Field $field) { |
|
143 | + return new static(array_filter($this->fields, function(Field $field) { |
|
144 | 144 | return $field->untagged(); |
145 | 145 | })); |
146 | 146 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function offsetGet($offset) |
183 | 183 | { |
184 | 184 | if (!isset($this->fields[$offset])) { |
185 | - throw new \RuntimeException('No field found by key [' . $offset . ']'); |
|
185 | + throw new \RuntimeException('No field found by key ['.$offset.']'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $this->fields[$offset]; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | public function offsetSet($offset, $value) |
192 | 192 | { |
193 | 193 | if (!$value instanceof Field) { |
194 | - throw new \InvalidArgumentException('Passed value must be of type ' . Field::class); |
|
194 | + throw new \InvalidArgumentException('Passed value must be of type '.Field::class); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | $this->fields[$offset] = $value; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | private function validateFields(array $fields) |
223 | 223 | { |
224 | - array_map(function (Field $field) { |
|
224 | + array_map(function(Field $field) { |
|
225 | 225 | }, $fields); |
226 | 226 | } |
227 | 227 |
@@ -43,16 +43,16 @@ |
||
43 | 43 | $filename = $filePayload['filename']; |
44 | 44 | |
45 | 45 | if (!$asset = AssetUploader::uploadFromBase64($base64EncodedFile, $filename)) { |
46 | - $responseContent['file-' . rand(1 - 999)] = [ |
|
46 | + $responseContent['file-'.rand(1-999)] = [ |
|
47 | 47 | 'error' => true, |
48 | - 'messages' => 'Afbeelding [' . $filename . '] kan niet worden opgeladen.', |
|
48 | + 'messages' => 'Afbeelding ['.$filename.'] kan niet worden opgeladen.', |
|
49 | 49 | ]; |
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | 53 | app(AddAsset::class)->add($model, $asset, MediaType::CONTENT, $request->input('locale', app()->getLocale())); |
54 | 54 | |
55 | - $responseContent['file-' . $asset->id] = [ |
|
55 | + $responseContent['file-'.$asset->id] = [ |
|
56 | 56 | 'url' => $asset->url(), |
57 | 57 | 'id' => $asset->id, |
58 | 58 | ]; |
@@ -41,7 +41,7 @@ |
||
41 | 41 | if ($urlRecord->isRedirect()) { |
42 | 42 | return 'Deze link bestaat reeds als redirect. Deze redirect zal bijgevolg worden verwijderd.'; |
43 | 43 | } |
44 | - return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="' . $this->editRouteOfOtherModel($urlRecord) . '">pas de andere pagina aan</a>.'; |
|
44 | + return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="'.$this->editRouteOfOtherModel($urlRecord).'">pas de andere pagina aan</a>.'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | private function editRouteOfOtherModel(UrlRecord $urlRecord): string |