@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | ->label('') |
| 36 | 36 | ]); |
| 37 | 37 | |
| 38 | - if (count($locales) < 2) return $fields; |
|
| 38 | + if (count($locales) < 2) { |
|
| 39 | + return $fields; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Add description to wildcard field only when there are locale values. |
| 41 | 43 | $wildCardField->label('Default link') |
@@ -71,7 +73,9 @@ discard block |
||
| 71 | 73 | continue; |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | - if(!isset($fields['url-slugs.'.$record->locale])) continue; |
|
| 76 | + if(!isset($fields['url-slugs.'.$record->locale])) { |
|
| 77 | + continue; |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | $fields['url-slugs.'.$record->locale] |
| 77 | 81 | ->setUrlRecord($record) |
@@ -14,15 +14,21 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | public static function fromRequest(Request $request = null, $locale = null) |
| 16 | 16 | { |
| 17 | - if(!$request) $request = request(); |
|
| 18 | - if(!$locale) $locale = app()->getLocale(); |
|
| 17 | + if(!$request) { |
|
| 18 | + $request = request(); |
|
| 19 | + } |
|
| 20 | + if(!$locale) { |
|
| 21 | + $locale = app()->getLocale(); |
|
| 22 | + } |
|
| 19 | 23 | |
| 20 | 24 | return static::fromSlug($request->path(), $locale); |
| 21 | 25 | } |
| 22 | 26 | |
| 23 | 27 | public static function fromSlug(string $slug, $locale = null) |
| 24 | 28 | { |
| 25 | - if(!$locale) $locale = app()->getLocale(); |
|
| 29 | + if(!$locale) { |
|
| 30 | + $locale = app()->getLocale(); |
|
| 31 | + } |
|
| 26 | 32 | |
| 27 | 33 | try{ |
| 28 | 34 | $urlRecord = UrlRecord::findBySlug($slug, $locale); |
@@ -42,8 +48,7 @@ discard block |
||
| 42 | 48 | } |
| 43 | 49 | |
| 44 | 50 | return new static($model->renderView(), 200); |
| 45 | - } |
|
| 46 | - catch(UrlRecordNotFound | NotFoundMorphKey $e) |
|
| 51 | + } catch(UrlRecordNotFound | NotFoundMorphKey $e) |
|
| 47 | 52 | { |
| 48 | 53 | if(config('thinktomorrow.chief.strict')){ throw $e; } |
| 49 | 54 | } |
@@ -31,7 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | private function rawSlugValue(): string |
| 33 | 33 | { |
| 34 | - if(!$this->urlRecord) return ''; |
|
| 34 | + if(!$this->urlRecord) { |
|
| 35 | + return ''; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $slug = $this->urlRecord->slug; |
| 37 | 39 | |
@@ -83,11 +83,9 @@ |
||
| 83 | 83 | })->each(function($existingRecord){ |
| 84 | 84 | $existingRecord->delete(); |
| 85 | 85 | }); |
| 86 | - } |
|
| 87 | - elseif($recordsWithSameLocale->isEmpty()){ |
|
| 86 | + } elseif($recordsWithSameLocale->isEmpty()){ |
|
| 88 | 87 | $this->createRecord($locale, $slug, $savingAsWildcard); |
| 89 | - } |
|
| 90 | - else{ |
|
| 88 | + } else{ |
|
| 91 | 89 | // Only replace the existing records that differ from the current passed slugs |
| 92 | 90 | $recordsWithSameLocale->each(function($existingRecord) use($slug, $savingAsWildcard){ |
| 93 | 91 | if($existingRecord->slug != $slug){ |
@@ -20,7 +20,9 @@ |
||
| 20 | 20 | foreach ($manager->fieldsWithAssistantFields() as $field) { |
| 21 | 21 | |
| 22 | 22 | // Custom save methods |
| 23 | - if($this->detectCustomSaveMethods($manager, $field)) continue; |
|
| 23 | + if($this->detectCustomSaveMethods($manager, $field)) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | // Media fields are treated separately |
| 26 | 28 | if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) { |
@@ -167,7 +167,9 @@ |
||
| 167 | 167 | $fields = $this->fields(); |
| 168 | 168 | |
| 169 | 169 | foreach($this->assistants() as $assistant){ |
| 170 | - if( ! method_exists($assistant, 'fields')) continue; |
|
| 170 | + if( ! method_exists($assistant, 'fields')) { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | $fields = $fields->merge($assistant->fields()); |
| 173 | 175 | } |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | |
| 25 | 25 | public function first(): ?Field |
| 26 | 26 | { |
| 27 | - if(!$this->any()) return null; |
|
| 27 | + if(!$this->any()) { |
|
| 28 | + return null; |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | return reset($this->fields); |
| 30 | 32 | } |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | try { |
| 30 | 30 | return view($this->viewPath(), $this->viewData())->render(); |
| 31 | - } |
|
| 32 | - catch(NotFoundView $e) { |
|
| 31 | + } catch(NotFoundView $e) { |
|
| 33 | 32 | if(config('thinktomorrow.chief.strict')){ |
| 34 | 33 | throw $e; |
| 35 | 34 | } |
@@ -56,7 +55,9 @@ discard block |
||
| 56 | 55 | */ |
| 57 | 56 | public function viewKey(): string |
| 58 | 57 | { |
| 59 | - if(property_exists($this, 'viewKey') && isset($this->viewKey)) return $this->viewKey; |
|
| 58 | + if(property_exists($this, 'viewKey') && isset($this->viewKey)) { |
|
| 59 | + return $this->viewKey; |
|
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | if($this instanceof MorphableContract){ |
| 62 | 63 | return $this->morphKey(); |
@@ -156,14 +156,15 @@ |
||
| 156 | 156 | /** @inheritdoc */ |
| 157 | 157 | public function url(string $locale = null): string |
| 158 | 158 | { |
| 159 | - if(!$locale) $locale = app()->getLocale(); |
|
| 159 | + if(!$locale) { |
|
| 160 | + $locale = app()->getLocale(); |
|
| 161 | + } |
|
| 160 | 162 | |
| 161 | 163 | try{ |
| 162 | 164 | $slug = MemoizedUrlRecord::findByModel($this, $locale)->slug; |
| 163 | 165 | |
| 164 | 166 | return $this->resolveUrl($locale, [$slug]); |
| 165 | - } |
|
| 166 | - catch(UrlRecordNotFound $e) |
|
| 167 | + } catch(UrlRecordNotFound $e) |
|
| 167 | 168 | { |
| 168 | 169 | return ''; |
| 169 | 170 | } |