@@ -65,8 +65,8 @@ discard block  | 
                                                    ||
| 65 | 65 | public static function getByModel(Model $model)  | 
                                                        
| 66 | 66 |      { | 
                                                        
| 67 | 67 |          return static::where('model_type', $model->getMorphClass()) | 
                                                        
| 68 | -                     ->where('model_id', $model->id) | 
                                                        |
| 69 | - ->get();  | 
                                                        |
| 68 | +                        ->where('model_id', $model->id) | 
                                                        |
| 69 | + ->get();  | 
                                                        |
| 70 | 70 | }  | 
                                                        
| 71 | 71 | |
| 72 | 72 | public static function findRecentRedirect(Model $model, string $locale): ?self  | 
                                                        
@@ -134,9 +134,9 @@ discard block  | 
                                                    ||
| 134 | 134 |          if ($ignoredModel) { | 
                                                        
| 135 | 135 |              $builder->whereNotIn('id', function ($query) use ($ignoredModel) { | 
                                                        
| 136 | 136 |                  $query->select('id') | 
                                                        
| 137 | -                      ->from('chief_urls') | 
                                                        |
| 138 | -                      ->where('model_type', '=', $ignoredModel->getMorphClass()) | 
                                                        |
| 139 | -                      ->where('model_id', '=', $ignoredModel->id); | 
                                                        |
| 137 | +                        ->from('chief_urls') | 
                                                        |
| 138 | +                        ->where('model_type', '=', $ignoredModel->getMorphClass()) | 
                                                        |
| 139 | +                        ->where('model_id', '=', $ignoredModel->id); | 
                                                        |
| 140 | 140 | });  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | 142 | |
@@ -74,7 +74,7 @@ discard block  | 
                                                    ||
| 74 | 74 |          return static::where('model_type', $model->getMorphClass()) | 
                                                        
| 75 | 75 |              ->where('model_id', $model->id) | 
                                                        
| 76 | 76 |              ->where('locale', $locale) | 
                                                        
| 77 | -            ->where('redirect_id','<>', null) | 
                                                        |
| 77 | +            ->where('redirect_id', '<>', null) | 
                                                        |
| 78 | 78 |              ->orderBy('redirect_id', 'ASC') | 
                                                        
| 79 | 79 | ->first();  | 
                                                        
| 80 | 80 | }  | 
                                                        
@@ -127,12 +127,12 @@ discard block  | 
                                                    ||
| 127 | 127 |              $builder->where('locale', $locale); | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | -        if (! $includeRedirects) { | 
                                                        |
| 130 | +        if (!$includeRedirects) { | 
                                                        |
| 131 | 131 |              $builder->whereNull('redirect_id'); | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 |          if ($ignoredModel) { | 
                                                        
| 135 | -            $builder->whereNotIn('id', function ($query) use ($ignoredModel) { | 
                                                        |
| 135 | +            $builder->whereNotIn('id', function($query) use ($ignoredModel) { | 
                                                        |
| 136 | 136 |                  $query->select('id') | 
                                                        
| 137 | 137 |                        ->from('chief_urls') | 
                                                        
| 138 | 138 |                        ->where('model_type', '=', $ignoredModel->getMorphClass()) | 
                                                        
@@ -56,7 +56,7 @@ discard block  | 
                                                    ||
| 56 | 56 | private function saveRecord(string $locale, ?string $slug)  | 
                                                        
| 57 | 57 |      { | 
                                                        
| 58 | 58 | // Existing ones for this locale?  | 
                                                        
| 59 | -        $nonRedirectsWithSameLocale = $this->existingRecords->filter(function ($record) use ($locale) { | 
                                                        |
| 59 | +        $nonRedirectsWithSameLocale = $this->existingRecords->filter(function($record) use ($locale) { | 
                                                        |
| 60 | 60 | return (  | 
                                                        
| 61 | 61 | $record->locale == $locale &&  | 
                                                        
| 62 | 62 | !$record->isRedirect()  | 
                                                        
@@ -65,7 +65,7 @@ discard block  | 
                                                    ||
| 65 | 65 | |
| 66 | 66 | // If slug entry is left empty, all existing records will be deleted  | 
                                                        
| 67 | 67 |          if (!$slug) { | 
                                                        
| 68 | -            $nonRedirectsWithSameLocale->each(function ($existingRecord) { | 
                                                        |
| 68 | +            $nonRedirectsWithSameLocale->each(function($existingRecord) { | 
                                                        |
| 69 | 69 | $existingRecord->delete();  | 
                                                        
| 70 | 70 | });  | 
                                                        
| 71 | 71 | |
@@ -81,7 +81,7 @@ discard block  | 
                                                    ||
| 81 | 81 | }  | 
                                                        
| 82 | 82 | |
| 83 | 83 | // Only replace the existing records that differ from the current passed slugs  | 
                                                        
| 84 | -        $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) { | 
                                                        |
| 84 | +        $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) { | 
                                                        |
| 85 | 85 |              if ($existingRecord->slug != $slug) { | 
                                                        
| 86 | 86 | $existingRecord->replaceAndRedirect(['slug' => $slug]);  | 
                                                        
| 87 | 87 | }  | 
                                                        
@@ -126,12 +126,12 @@ discard block  | 
                                                    ||
| 126 | 126 | */  | 
                                                        
| 127 | 127 | private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void  | 
                                                        
| 128 | 128 |      { | 
                                                        
| 129 | -        $existingRecords->filter(function ($record) use ($locale) { | 
                                                        |
| 129 | +        $existingRecords->filter(function($record) use ($locale) { | 
                                                        |
| 130 | 130 | return (  | 
                                                        
| 131 | 131 | $record->locale == $locale &&  | 
                                                        
| 132 | 132 | $record->isRedirect()  | 
                                                        
| 133 | 133 | );  | 
                                                        
| 134 | -        })->each(function ($existingRecord) use ($slug) { | 
                                                        |
| 134 | +        })->each(function($existingRecord) use ($slug) { | 
                                                        |
| 135 | 135 |              if ($existingRecord->slug == $slug) { | 
                                                        
| 136 | 136 | $existingRecord->delete();  | 
                                                        
| 137 | 137 | }  | 
                                                        
@@ -140,15 +140,15 @@ discard block  | 
                                                    ||
| 140 | 140 | |
| 141 | 141 | private function deleteIdenticalRecords($existingRecords): void  | 
                                                        
| 142 | 142 |      { | 
                                                        
| 143 | - if($this->strict) return;  | 
                                                        |
| 143 | + if ($this->strict) return;  | 
                                                        |
| 144 | 144 | |
| 145 | 145 | // The old homepage url should be removed since this is no longer in effect.  | 
                                                        
| 146 | 146 | // In case of any redirect to this old homepage, the last used redirect is now back in effect.  | 
                                                        
| 147 | -        $existingRecords->reject(function($existingRecord){ | 
                                                        |
| 147 | +        $existingRecords->reject(function($existingRecord) { | 
                                                        |
| 148 | 148 | return (  | 
                                                        
| 149 | 149 | $existingRecord->model_type == $this->model->getMorphClass() &&  | 
                                                        
| 150 | 150 | $existingRecord->model_id == $this->model->id);  | 
                                                        
| 151 | -        })->each(function($existingRecord){ | 
                                                        |
| 151 | +        })->each(function($existingRecord) { | 
                                                        |
| 152 | 152 | |
| 153 | 153 | // TODO: if there is a redirect to this page, we'll take this one as the new url  | 
                                                        
| 154 | 154 | $existingRecord->delete();  | 
                                                        
@@ -162,7 +162,7 @@ discard block  | 
                                                    ||
| 162 | 162 | */  | 
                                                        
| 163 | 163 | private function prependBaseUrlSegment(string $slug, $locale): string  | 
                                                        
| 164 | 164 |      { | 
                                                        
| 165 | - $slugWithBaseSegment = $this->model->baseUrlSegment($locale) . '/' . $slug;  | 
                                                        |
| 165 | + $slugWithBaseSegment = $this->model->baseUrlSegment($locale).'/'.$slug;  | 
                                                        |
| 166 | 166 | $slugWithBaseSegment = trim($slugWithBaseSegment, '/');  | 
                                                        
| 167 | 167 | |
| 168 | 168 | // If slug with base segment is empty string, it means that the passed slug was probably a "/" character.  | 
                                                        
@@ -140,7 +140,9 @@  | 
                                                    ||
| 140 | 140 | |
| 141 | 141 | private function deleteIdenticalRecords($existingRecords): void  | 
                                                        
| 142 | 142 |      { | 
                                                        
| 143 | - if($this->strict) return;  | 
                                                        |
| 143 | +        if($this->strict) { | 
                                                        |
| 144 | + return;  | 
                                                        |
| 145 | + }  | 
                                                        |
| 144 | 146 | |
| 145 | 147 | // The old homepage url should be removed since this is no longer in effect.  | 
                                                        
| 146 | 148 | // In case of any redirect to this old homepage, the last used redirect is now back in effect.  | 
                                                        
@@ -23,10 +23,10 @@ discard block  | 
                                                    ||
| 23 | 23 | |
| 24 | 24 | public function handle(string $locale): void  | 
                                                        
| 25 | 25 |      { | 
                                                        
| 26 | -        try{ | 
                                                        |
| 26 | +        try { | 
                                                        |
| 27 | 27 | $currentUrlRecord = UrlRecord::findByModel($this->model, $locale);  | 
                                                        
| 28 | 28 | |
| 29 | -            if($recentRedirect = UrlRecord::findRecentRedirect($this->model, $locale)){ | 
                                                        |
| 29 | +            if ($recentRedirect = UrlRecord::findRecentRedirect($this->model, $locale)) { | 
                                                        |
| 30 | 30 | |
| 31 | 31 | $recentRedirectSlug = $recentRedirect->slug;  | 
                                                        
| 32 | 32 | $recentRedirect->delete();  | 
                                                        
@@ -34,7 +34,7 @@ discard block  | 
                                                    ||
| 34 | 34 | $currentUrlRecord->replaceAndRedirect(['slug' => $recentRedirectSlug]);  | 
                                                        
| 35 | 35 | }  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | - catch(UrlRecordNotFound $e)  | 
                                                        |
| 37 | + catch (UrlRecordNotFound $e)  | 
                                                        |
| 38 | 38 |          { | 
                                                        
| 39 | 39 | // No url present so nothing to do here...  | 
                                                        
| 40 | 40 | }  | 
                                                        
@@ -33,8 +33,7 @@  | 
                                                    ||
| 33 | 33 | |
| 34 | 34 | $currentUrlRecord->replaceAndRedirect(['slug' => $recentRedirectSlug]);  | 
                                                        
| 35 | 35 | }  | 
                                                        
| 36 | - }  | 
                                                        |
| 37 | - catch(UrlRecordNotFound $e)  | 
                                                        |
| 36 | + } catch(UrlRecordNotFound $e)  | 
                                                        |
| 38 | 37 |          { | 
                                                        
| 39 | 38 | // No url present so nothing to do here...  | 
                                                        
| 40 | 39 | }  | 
                                                        
@@ -15,11 +15,11 @@ discard block  | 
                                                    ||
| 15 | 15 | */  | 
                                                        
| 16 | 16 | public static function allOnlineModels(bool $onlySingles = false): array  | 
                                                        
| 17 | 17 |      { | 
                                                        
| 18 | -        return chiefMemoize('all-online-models', function () use($onlySingles) { | 
                                                        |
| 18 | +        return chiefMemoize('all-online-models', function() use($onlySingles) { | 
                                                        |
| 19 | 19 | |
| 20 | 20 |              $builder = UrlRecord::whereNull('redirect_id')->select('model_type', 'model_id')->groupBy('model_type', 'model_id'); | 
                                                        
| 21 | 21 | |
| 22 | -            if($onlySingles) { | 
                                                        |
| 22 | +            if ($onlySingles) { | 
                                                        |
| 23 | 23 |                  $builder->where('model_type', 'singles'); | 
                                                        
| 24 | 24 | }  | 
                                                        
| 25 | 25 | |
@@ -28,9 +28,9 @@ discard block  | 
                                                    ||
| 28 | 28 | });  | 
                                                        
| 29 | 29 | |
| 30 | 30 | // Get model for each of these records...  | 
                                                        
| 31 | -            $models = $liveUrlRecords->map(function($record, $key){ | 
                                                        |
| 31 | +            $models = $liveUrlRecords->map(function($record, $key) { | 
                                                        |
| 32 | 32 | return Morphables::instance($key)->find($record->toArray());  | 
                                                        
| 33 | -            })->each->reject(function ($model) { | 
                                                        |
| 33 | +            })->each->reject(function($model) { | 
                                                        |
| 34 | 34 | // Invalid references to archived or removed models where url record still exists.  | 
                                                        
| 35 | 35 | return is_null($model);  | 
                                                        
| 36 | 36 | })->flatten();  | 
                                                        
@@ -18,7 +18,7 @@ discard block  | 
                                                    ||
| 18 | 18 | |
| 19 | 19 | public static function redirectsFromModel(ProvidesUrl $model)  | 
                                                        
| 20 | 20 |      { | 
                                                        
| 21 | -        $records = MemoizedUrlRecord::getByModel($model)->reject(function ($record) { | 
                                                        |
| 21 | +        $records = MemoizedUrlRecord::getByModel($model)->reject(function($record) { | 
                                                        |
| 22 | 22 | return !$record->isRedirect();  | 
                                                        
| 23 | 23 |          })->sortByDesc('created_at'); | 
                                                        
| 24 | 24 | |
@@ -29,7 +29,7 @@ discard block  | 
                                                    ||
| 29 | 29 | $fields[$key] = UrlSlugField::make($key)  | 
                                                        
| 30 | 30 | ->setUrlRecord($record)  | 
                                                        
| 31 | 31 | ->setBaseUrlSegment($model->baseUrlSegment($record->locale))  | 
                                                        
| 32 | - ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)) .'/');  | 
                                                        |
| 32 | + ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)).'/');  | 
                                                        |
| 33 | 33 | }  | 
                                                        
| 34 | 34 | |
| 35 | 35 | return $fields;  | 
                                                        
@@ -61,10 +61,10 @@ discard block  | 
                                                    ||
| 61 | 61 | $fields = new static([]);  | 
                                                        
| 62 | 62 | |
| 63 | 63 |          foreach ($locales as $locale) { | 
                                                        
| 64 | -            $fields['url-slugs.' . $locale] = UrlSlugField::make('url-slugs.' . $locale) | 
                                                        |
| 64 | +            $fields['url-slugs.'.$locale] = UrlSlugField::make('url-slugs.'.$locale) | 
                                                        |
| 65 | 65 | ->setBaseUrlSegment($model->baseUrlSegment($locale))  | 
                                                        
| 66 | - ->prepend($model->resolveUrl($locale, $model->baseUrlSegment($locale)) .'/')  | 
                                                        |
| 67 | -                                                ->name('url-slugs[' . $locale . ']') | 
                                                        |
| 66 | + ->prepend($model->resolveUrl($locale, $model->baseUrlSegment($locale)).'/')  | 
                                                        |
| 67 | +                                                ->name('url-slugs['.$locale.']') | 
                                                        |
| 68 | 68 | ->label($locale);  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
@@ -77,7 +77,7 @@ discard block  | 
                                                    ||
| 77 | 77 | */  | 
                                                        
| 78 | 78 | private static function fillWithExistingValues(ProvidesUrl $model, self $fields): void  | 
                                                        
| 79 | 79 |      { | 
                                                        
| 80 | -        $records = UrlRecord::getByModel($model)->reject(function ($record) { | 
                                                        |
| 80 | +        $records = UrlRecord::getByModel($model)->reject(function($record) { | 
                                                        |
| 81 | 81 | return $record->isRedirect();  | 
                                                        
| 82 | 82 |          })->sortBy('locale'); | 
                                                        
| 83 | 83 | |
@@ -89,7 +89,7 @@ discard block  | 
                                                    ||
| 89 | 89 | $fields['url-slugs.'.$record->locale]  | 
                                                        
| 90 | 90 | ->setUrlRecord($record)  | 
                                                        
| 91 | 91 | ->setBaseUrlSegment($model->baseUrlSegment($record->locale))  | 
                                                        
| 92 | - ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)) .'/');  | 
                                                        |
| 92 | + ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)).'/');  | 
                                                        |
| 93 | 93 | }  | 
                                                        
| 94 | 94 | }  | 
                                                        
| 95 | 95 | }  | 
                                                        
@@ -25,10 +25,10 @@ discard block  | 
                                                    ||
| 25 | 25 | |
| 26 | 26 | public function manager(Manager $manager)  | 
                                                        
| 27 | 27 |      { | 
                                                        
| 28 | - $this->manager = $manager;  | 
                                                        |
| 28 | + $this->manager = $manager;  | 
                                                        |
| 29 | 29 | |
| 30 | -        if (! $manager->model() instanceof ProvidesUrl) { | 
                                                        |
| 31 | -            throw new \Exception('UrlAssistant requires the model interfaced by ' . ProvidesUrl::class . '.'); | 
                                                        |
| 30 | +        if (!$manager->model() instanceof ProvidesUrl) { | 
                                                        |
| 31 | +            throw new \Exception('UrlAssistant requires the model interfaced by '.ProvidesUrl::class.'.'); | 
                                                        |
| 32 | 32 | }  | 
                                                        
| 33 | 33 | |
| 34 | 34 | $this->model = $manager->model();  | 
                                                        
@@ -56,14 +56,14 @@ discard block  | 
                                                    ||
| 56 | 56 |              InputField::make('url-slugs') | 
                                                        
| 57 | 57 | ->validation(  | 
                                                        
| 58 | 58 | [  | 
                                                        
| 59 | - 'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null),],  | 
                                                        |
| 59 | + 'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null), ],  | 
                                                        |
| 60 | 60 | ],  | 
                                                        
| 61 | 61 | [],  | 
                                                        
| 62 | 62 | [  | 
                                                        
| 63 | 63 | 'url-slugs.*' => 'taalspecifieke link',  | 
                                                        
| 64 | 64 | ])  | 
                                                        
| 65 | 65 |                  ->view('chief::back._fields.url-slugs') | 
                                                        
| 66 | - ->viewData(['fields' => UrlSlugFields::fromModel($this->model) ]),  | 
                                                        |
| 66 | + ->viewData(['fields' => UrlSlugFields::fromModel($this->model)]),  | 
                                                        |
| 67 | 67 | ]);  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
@@ -75,7 +75,7 @@ discard block  | 
                                                    ||
| 75 | 75 | // TODO: we should just fetch the homepages and push that instead...  | 
                                                        
| 76 | 76 |          UrlRecord::getByModel($this->model)->reject(function($record) { | 
                                                        
| 77 | 77 | return ($record->isRedirect() || !$record->isHomepage());  | 
                                                        
| 78 | -        })->each(function($record){ | 
                                                        |
| 78 | +        })->each(function($record) { | 
                                                        |
| 79 | 79 | app(ChangeHomepage::class)->onUrlChanged($record);  | 
                                                        
| 80 | 80 | });  | 
                                                        
| 81 | 81 | }  | 
                                                        
@@ -61,15 +61,15 @@ discard block  | 
                                                    ||
| 61 | 61 |      { | 
                                                        
| 62 | 62 | $permission = 'update-page';  | 
                                                        
| 63 | 63 | |
| 64 | -        if (in_array($verb, ['index','show'])) { | 
                                                        |
| 64 | +        if (in_array($verb, ['index', 'show'])) { | 
                                                        |
| 65 | 65 | $permission = 'view-page';  | 
                                                        
| 66 | -        } elseif (in_array($verb, ['create','store'])) { | 
                                                        |
| 66 | +        } elseif (in_array($verb, ['create', 'store'])) { | 
                                                        |
| 67 | 67 | $permission = 'create-page';  | 
                                                        
| 68 | 68 |          } elseif (in_array($verb, ['delete'])) { | 
                                                        
| 69 | 69 | $permission = 'delete-page';  | 
                                                        
| 70 | 70 | }  | 
                                                        
| 71 | 71 | |
| 72 | -        if (! auth()->guard('chief')->user()->hasPermissionTo($permission)) { | 
                                                        |
| 72 | +        if (!auth()->guard('chief')->user()->hasPermissionTo($permission)) { | 
                                                        |
| 73 | 73 | throw NotAllowedManagerRoute::notAllowedPermission($permission, $this);  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | }  | 
                                                        
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | public function fieldArrangement($key = null): FieldArrangement  | 
                                                        
| 131 | 131 |      { | 
                                                        
| 132 | 132 |          if ($key == 'create') { | 
                                                        
| 133 | -            return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function ($field) { | 
                                                        |
| 133 | +            return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function($field) { | 
                                                        |
| 134 | 134 | return in_array($field->key, ['title']);  | 
                                                        
| 135 | 135 | }));  | 
                                                        
| 136 | 136 | }  | 
                                                        
@@ -152,8 +152,8 @@ discard block  | 
                                                    ||
| 152 | 152 |          if ($this->model->id) { | 
                                                        
| 153 | 153 | return parent::details()  | 
                                                        
| 154 | 154 |                  ->set('title', $this->model->title) | 
                                                        
| 155 | -                ->set('intro', 'Aangepast ' . $this->model->updated_at->format('d/m/Y H:i')) | 
                                                        |
| 156 | -                ->set('context', '<span class="inline-s">' . $this->assistant('publish')->publicationStatusAsLabel() . '</span>'); | 
                                                        |
| 155 | +                ->set('intro', 'Aangepast '.$this->model->updated_at->format('d/m/Y H:i')) | 
                                                        |
| 156 | +                ->set('context', '<span class="inline-s">'.$this->assistant('publish')->publicationStatusAsLabel().'</span>'); | 
                                                        |
| 157 | 157 | }  | 
                                                        
| 158 | 158 | |
| 159 | 159 | return parent::details();  | 
                                                        
@@ -162,7 +162,7 @@ discard block  | 
                                                    ||
| 162 | 162 | public function saveFields(Request $request)  | 
                                                        
| 163 | 163 |      { | 
                                                        
| 164 | 164 | // Store the morph_key upon creation  | 
                                                        
| 165 | -        if ($this->model instanceof MorphableContract && ! $this->model->morph_key) { | 
                                                        |
| 165 | +        if ($this->model instanceof MorphableContract && !$this->model->morph_key) { | 
                                                        |
| 166 | 166 | $this->model->morph_key = $this->model->morphKey();  | 
                                                        
| 167 | 167 | }  | 
                                                        
| 168 | 168 | |
@@ -207,7 +207,7 @@ discard block  | 
                                                    ||
| 207 | 207 |              if (is_array_empty($translation)) { | 
                                                        
| 208 | 208 | |
| 209 | 209 | // Nullify all values  | 
                                                        
| 210 | -                $trans[$locale] = array_map(function ($value) { | 
                                                        |
| 210 | +                $trans[$locale] = array_map(function($value) { | 
                                                        |
| 211 | 211 | return null;  | 
                                                        
| 212 | 212 | }, $translation);  | 
                                                        
| 213 | 213 | continue;  | 
                                                        
@@ -28,13 +28,13 @@ discard block  | 
                                                    ||
| 28 | 28 | // }  | 
                                                        
| 29 | 29 | // }  | 
                                                        
| 30 | 30 | |
| 31 | -        foreach($flatReferences as $locale => $flatReferenceString) { | 
                                                        |
| 31 | +        foreach ($flatReferences as $locale => $flatReferenceString) { | 
                                                        |
| 32 | 32 | |
| 33 | -            if(!$flatReferenceString) { | 
                                                        |
| 33 | +            if (!$flatReferenceString) { | 
                                                        |
| 34 | 34 | |
| 35 | 35 | // TODO: when empty we'll remove the entry, we'll also want to revert to last redirect.  | 
                                                        
| 36 | 36 | |
| 37 | -                if(isset($existingValues[$locale])) { | 
                                                        |
| 37 | +                if (isset($existingValues[$locale])) { | 
                                                        |
| 38 | 38 | $flatReferenceInstance = FlatReferenceFactory::fromString(($existingValues[$locale]));  | 
                                                        
| 39 | 39 | (new RevertUrlSlug($flatReferenceInstance->instance()))->handle($locale);  | 
                                                        
| 40 | 40 | |
@@ -53,7 +53,7 @@ discard block  | 
                                                    ||
| 53 | 53 |      { | 
                                                        
| 54 | 54 | $model = Morphables::instance($urlRecord->model_type)->find($urlRecord->model_id);  | 
                                                        
| 55 | 55 | |
| 56 | -        if(!$homepage = Setting::findByKey(Setting::HOMEPAGE)){ | 
                                                        |
| 56 | +        if (!$homepage = Setting::findByKey(Setting::HOMEPAGE)) { | 
                                                        |
| 57 | 57 | $homepage = Setting::create(['key' => Setting::HOMEPAGE, 'value' => []]);  | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
@@ -57,9 +57,9 @@ discard block  | 
                                                    ||
| 57 | 57 |      { | 
                                                        
| 58 | 58 | $existingHomepageValue = [];  | 
                                                        
| 59 | 59 | |
| 60 | - foreach($this->fields() as $key => $field)  | 
                                                        |
| 60 | + foreach ($this->fields() as $key => $field)  | 
                                                        |
| 61 | 61 |          { | 
                                                        
| 62 | -            if(!$setting = Setting::where('key', $key)->first()) { | 
                                                        |
| 62 | +            if (!$setting = Setting::where('key', $key)->first()) { | 
                                                        |
| 63 | 63 | Setting::create([  | 
                                                        
| 64 | 64 | 'key' => $key,  | 
                                                        
| 65 | 65 | 'value' => $request->get($key, ''),  | 
                                                        
@@ -68,7 +68,7 @@ discard block  | 
                                                    ||
| 68 | 68 | continue;  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | -            if($key === Setting::HOMEPAGE) { | 
                                                        |
| 71 | +            if ($key === Setting::HOMEPAGE) { | 
                                                        |
| 72 | 72 | $existingHomepageValue = $setting->value;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block  | 
                                                    ||
| 76 | 76 | }  | 
                                                        
| 77 | 77 | |
| 78 | 78 | // A changed homepage needs to be reflected in the urls as well in order to respond to incoming requests.  | 
                                                        
| 79 | -        if($request->filled(Setting::HOMEPAGE)) { | 
                                                        |
| 79 | +        if ($request->filled(Setting::HOMEPAGE)) { | 
                                                        |
| 80 | 80 | app(ChangeHomepage::class)->onSettingChanged($existingHomepageValue);  | 
                                                        
| 81 | 81 | }  | 
                                                        
| 82 | 82 | }  |