@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | $request->input('images.'.$field->getName(), []), |
| 17 | 17 | ], $field, $request); |
| 18 | 18 | |
| 19 | - foreach([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) { |
|
| 20 | - foreach($mediaRequest->getByKey($action) as $input) { |
|
| 19 | + foreach ([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) { |
|
| 20 | + foreach ($mediaRequest->getByKey($action) as $input) { |
|
| 21 | 21 | $this->$action($model, $input); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | private function new(HasAsset $model, MediaRequestInput $mediaRequestInput): Asset |
| 29 | 29 | { |
| 30 | - if($mediaRequestInput->metadata('existing_asset')) { |
|
| 30 | + if ($mediaRequestInput->metadata('existing_asset')) { |
|
| 31 | 31 | return $this->newExistingAsset($model, $mediaRequestInput); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | protected function createNewAsset(HasAsset $model, MediaRequestInput $mediaRequestInput): Asset |
| 61 | 61 | { |
| 62 | - if($mediaRequestInput->metadata('existing_asset')) { |
|
| 62 | + if ($mediaRequestInput->metadata('existing_asset')) { |
|
| 63 | 63 | return Asset::find($mediaRequestInput->value()); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | $request->input('files.'.$field->getName(), []), |
| 20 | 20 | ], $field, $request); |
| 21 | 21 | |
| 22 | - foreach([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) { |
|
| 23 | - foreach($mediaRequest->getByKey($action) as $input) { |
|
| 22 | + foreach ([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) { |
|
| 23 | + foreach ($mediaRequest->getByKey($action) as $input) { |
|
| 24 | 24 | $this->$action($model, $input); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | private function new(HasAsset $model, MediaRequestInput $mediaRequestInput): Asset |
| 33 | 33 | { |
| 34 | - if($mediaRequestInput->metadata('existing_asset')) { |
|
| 34 | + if ($mediaRequestInput->metadata('existing_asset')) { |
|
| 35 | 35 | return $this->newExistingAsset($model, $mediaRequestInput); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $mediaRequest = new MediaRequest(); |
| 41 | 41 | |
| 42 | - foreach($requests as $requestData){ |
|
| 43 | - foreach($requestData as $locale => $filesPerLocale) { |
|
| 44 | - foreach($filesPerLocale as $action => $files) { |
|
| 42 | + foreach ($requests as $requestData) { |
|
| 43 | + foreach ($requestData as $locale => $filesPerLocale) { |
|
| 44 | + foreach ($filesPerLocale as $action => $files) { |
|
| 45 | 45 | |
| 46 | - if(!is_array($files) || !in_array($action, [MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH])) { |
|
| 46 | + if (!is_array($files) || !in_array($action, [MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH])) { |
|
| 47 | 47 | throw new \InvalidArgumentException('Malformed request data. Files are expected to be passed in a localized array.'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - foreach($files as $k => $file) { |
|
| 50 | + foreach ($files as $k => $file) { |
|
| 51 | 51 | $mediaRequest->add($action, new MediaRequestInput( |
| 52 | 52 | $file, $locale, $field->getKey(), [ |
| 53 | 53 | 'index' => $k, // index key is used for replace method to indicate the current asset id |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected function sluggifyFilename(string $filename): string |
| 93 | 93 | { |
| 94 | - if(false === strpos($filename, '.')) return $filename; |
|
| 94 | + if (false === strpos($filename, '.')) return $filename; |
|
| 95 | 95 | |
| 96 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 96 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 97 | 97 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 98 | 98 | |
| 99 | - return Str::slug($filename) . '.' . $extension; |
|
| 99 | + return Str::slug($filename).'.'.$extension; |
|
| 100 | 100 | } |
| 101 | 101 | } |
@@ -10,19 +10,19 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | $value = $this->normalizePayload($value); |
| 12 | 12 | |
| 13 | - foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) { |
|
| 14 | - foreach($value[$type] as $file) { |
|
| 15 | - if($file && false !== $this->validateMimetypes($attribute, $file, $params)) { |
|
| 13 | + foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) { |
|
| 14 | + foreach ($value[$type] as $file) { |
|
| 15 | + if ($file && false !== $this->validateMimetypes($attribute, $file, $params)) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $validator->setCustomMessages([ |
| 22 | - 'imagefield_mimetypes' => 'De :attribute is niet het juiste bestandstype. Volgende types zijn geldig: ' . implode(', ', $params), |
|
| 22 | + 'imagefield_mimetypes' => 'De :attribute is niet het juiste bestandstype. Volgende types zijn geldig: '.implode(', ', $params), |
|
| 23 | 23 | ]); |
| 24 | 24 | |
| 25 | - if(!isset($validator->customAttributes[$attribute])) { |
|
| 25 | + if (!isset($validator->customAttributes[$attribute])) { |
|
| 26 | 26 | $validator->addCustomAttributes([ |
| 27 | 27 | $attribute => 'afbeelding', |
| 28 | 28 | ]); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function validateMimetypes($attribute, $value, $parameters) |
| 36 | 36 | { |
| 37 | - if($this->refersToExistingAsset($value)) { |
|
| 37 | + if ($this->refersToExistingAsset($value)) { |
|
| 38 | 38 | return $this->validateAssetMimetypes($this->existingAsset($value), $parameters); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->format = $format; |
| 36 | 36 | $this->placeholders = $this->payload = $this->keysToBeRemoved = []; |
| 37 | 37 | |
| 38 | - $this->requiredLocale((string) config('app.fallback_locale', 'nl')); |
|
| 38 | + $this->requiredLocale((string)config('app.fallback_locale', 'nl')); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public static function fromFormat(string $format) |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $names = [$this->format]; |
| 49 | 49 | |
| 50 | - foreach($this->filters as $filter){ |
|
| 50 | + foreach ($this->filters as $filter) { |
|
| 51 | 51 | $names = call_user_func_array([$this, $filter], [$names]); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | $newKeySet = []; |
| 89 | 89 | foreach ($keys as $i => $key) { |
| 90 | 90 | |
| 91 | - if(count($replacements) < 1) { |
|
| 91 | + if (count($replacements) < 1) { |
|
| 92 | 92 | $newKeySet[] = $key; |
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | foreach ($replacements as $replacement) { |
| 97 | - $newKeySet[] = str_replace(':' . $placeholder, $replacement, $key); |
|
| 97 | + $newKeySet[] = str_replace(':'.$placeholder, $replacement, $key); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $filteredKeys = $keys; |
| 110 | 110 | |
| 111 | - foreach($this->keysToBeRemoved as $keyToBeRemoved) { |
|
| 111 | + foreach ($this->keysToBeRemoved as $keyToBeRemoved) { |
|
| 112 | 112 | $pattern = preg_quote($keyToBeRemoved, '#'); |
| 113 | 113 | |
| 114 | 114 | /* Any asterix which work as an wildcard of characters */ |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $pattern = str_replace('\*', '(.+)', $pattern); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - foreach($filteredKeys as $k => $filteredKey) { |
|
| 119 | + foreach ($filteredKeys as $k => $filteredKey) { |
|
| 120 | 120 | if (preg_match("#$pattern#", $filteredKey)) { |
| 121 | 121 | unset($filteredKeys[$k]); |
| 122 | 122 | } |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | // Remove locales that are considered empty in the request payload |
| 138 | 138 | foreach ($this->payload['trans'] as $locale => $values) { |
| 139 | - if ($locale == $this->requiredLocale || ! is_array_empty($values)) { |
|
| 139 | + if ($locale == $this->requiredLocale || !is_array_empty($values)) { |
|
| 140 | 140 | continue; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Remove all 'trans' entries for this locale |
| 144 | - foreach($filteredKeys as $i => $key){ |
|
| 145 | - if(Str::startsWith($key, 'trans.'.$locale)) { |
|
| 144 | + foreach ($filteredKeys as $i => $key) { |
|
| 145 | + if (Str::startsWith($key, 'trans.'.$locale)) { |
|
| 146 | 146 | unset($filteredKeys[$i]); |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $filteredKeys = $keys; |
| 157 | 157 | |
| 158 | - foreach($filteredKeys as $i => $key) { |
|
| 158 | + foreach ($filteredKeys as $i => $key) { |
|
| 159 | 159 | if (!Str::startsWith($key, ['images.', 'files.'])) continue; |
| 160 | 160 | |
| 161 | 161 | $payload = Arr::get($this->payload, $key); |
| 162 | 162 | |
| 163 | 163 | // If the payload is empty and this is not the entry for the required locale |
| 164 | - if(!$payload && !Str::endsWith($key, '.'.$this->requiredLocale)) { |
|
| 164 | + if (!$payload && !Str::endsWith($key, '.'.$this->requiredLocale)) { |
|
| 165 | 165 | unset($filteredKeys[$i]); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -156,7 +156,9 @@ |
||
| 156 | 156 | $filteredKeys = $keys; |
| 157 | 157 | |
| 158 | 158 | foreach($filteredKeys as $i => $key) { |
| 159 | - if (!Str::startsWith($key, ['images.', 'files.'])) continue; |
|
| 159 | + if (!Str::startsWith($key, ['images.', 'files.'])) { |
|
| 160 | + continue; |
|
| 161 | + } |
|
| 160 | 162 | |
| 161 | 163 | $payload = Arr::get($this->payload, $key); |
| 162 | 164 | |