@@ -18,11 +18,11 @@ |
||
18 | 18 | $urlRecord = UrlRecord::find($id); |
19 | 19 | |
20 | 20 | if (!$urlRecord) { |
21 | - return response()->json(['No url record found by id ' . $id], 500); |
|
21 | + return response()->json(['No url record found by id '.$id], 500); |
|
22 | 22 | } |
23 | 23 | |
24 | - if (! $urlRecord->isRedirect()) { |
|
25 | - return response()->json(['Url with id ' . $id . ' is not a redirect'], 500); |
|
24 | + if (!$urlRecord->isRedirect()) { |
|
25 | + return response()->json(['Url with id '.$id.' is not a redirect'], 500); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $this->pointChildRedirectsToParent($urlRecord, $urlRecord->redirect_id); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function check(Request $request) |
17 | 17 | { |
18 | 18 | /** @var ProvidesUrl|Model $model */ |
19 | - $model = (new ModelReference($request->modelClass, (int) $request->modelId))->instance(); |
|
19 | + $model = (new ModelReference($request->modelClass, (int)$request->modelId))->instance(); |
|
20 | 20 | |
21 | 21 | // Trim slashes if any |
22 | 22 | $slug = ($request->slug !== '/') ? trim($request->slug, '/') : $request->slug; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if ($urlRecord->isRedirect()) { |
41 | 41 | return 'Deze link bestaat reeds als redirect. Deze redirect zal bijgevolg worden verwijderd.'; |
42 | 42 | } |
43 | - return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="' . $this->editRouteOfOtherModel($urlRecord) . '">pas de andere pagina aan</a>.'; |
|
43 | + return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="'.$this->editRouteOfOtherModel($urlRecord).'">pas de andere pagina aan</a>.'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | private function editRouteOfOtherModel(UrlRecord $urlRecord): string |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ->first(); |
37 | 37 | |
38 | 38 | if (!$record) { |
39 | - throw new UrlRecordNotFound('No url record found for model [' . $model->getMorphClass() . '@' . $model->id . '] for locale [' . $locale . '].'); |
|
39 | + throw new UrlRecordNotFound('No url record found for model ['.$model->getMorphClass().'@'.$model->id.'] for locale ['.$locale.'].'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $record; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public static function getByModel(Model $model) |
46 | 46 | { |
47 | - return chiefMemoize('url-records-get-by-model', function ($model) { |
|
47 | + return chiefMemoize('url-records-get-by-model', function($model) { |
|
48 | 48 | return parent::getByModel($model); |
49 | 49 | }, [$model]); |
50 | 50 | } |
@@ -18,14 +18,14 @@ 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 | |
25 | 25 | $fields = new static([]); |
26 | 26 | |
27 | 27 | foreach ($records as $record) { |
28 | - $key = 'redirects-' . $record->locale . '-' . $record->slug; |
|
28 | + $key = 'redirects-'.$record->locale.'-'.$record->slug; |
|
29 | 29 | $fields[$key] = UrlSlugField::make($key) |
30 | 30 | ->setUrlRecord($record) |
31 | 31 | ->setFullUrl($model->resolveUrl($record->locale, $record->slug)); |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | $fields = new static([]); |
61 | 61 | |
62 | 62 | foreach ($locales as $locale) { |
63 | - $fields['url-slugs.' . $locale] = UrlSlugField::make('url-slugs.' . $locale) |
|
63 | + $fields['url-slugs.'.$locale] = UrlSlugField::make('url-slugs.'.$locale) |
|
64 | 64 | ->setBaseUrlSegment($model->baseUrlSegment($locale)) |
65 | - ->prepend($model->resolveUrl($locale, $model->baseUrlSegment($locale)) . '/') |
|
66 | - ->name('url-slugs[' . $locale . ']') |
|
65 | + ->prepend($model->resolveUrl($locale, $model->baseUrlSegment($locale)).'/') |
|
66 | + ->name('url-slugs['.$locale.']') |
|
67 | 67 | ->label($locale); |
68 | 68 | } |
69 | 69 | |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private static function fillWithExistingValues(ProvidesUrl $model, self $fields): void |
78 | 78 | { |
79 | - $records = UrlRecord::getByModel($model)->reject(function ($record) { |
|
79 | + $records = UrlRecord::getByModel($model)->reject(function($record) { |
|
80 | 80 | return $record->isRedirect(); |
81 | 81 | })->sortBy('locale'); |
82 | 82 | |
83 | 83 | foreach ($records as $record) { |
84 | - if (!isset($fields['url-slugs.' . $record->locale])) { |
|
84 | + if (!isset($fields['url-slugs.'.$record->locale])) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
88 | - $fields['url-slugs.' . $record->locale] |
|
88 | + $fields['url-slugs.'.$record->locale] |
|
89 | 89 | ->setUrlRecord($record) |
90 | 90 | ->setBaseUrlSegment($model->baseUrlSegment($record->locale)) |
91 | - ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)) . '/'); |
|
91 | + ->prepend($model->resolveUrl($record->locale, $model->baseUrlSegment($record->locale)).'/'); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Site\Urls\Field; |
6 | 6 | |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | // Push update to homepage setting value |
21 | 21 | // TODO: we should just fetch the homepages and push that instead... |
22 | - UrlRecord::getByModel($model)->reject(function ($record) { |
|
22 | + UrlRecord::getByModel($model)->reject(function($record) { |
|
23 | 23 | return ($record->isRedirect() || !$record->isHomepage()); |
24 | - })->each(function ($record) { |
|
24 | + })->each(function($record) { |
|
25 | 25 | app(ChangeHomepage::class)->onUrlChanged($record); |
26 | 26 | }); |
27 | 27 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | return $this->fullUrl |
44 | 44 | ? $this->fullUrl |
45 | - : $this->prepend . $this->getValue(); |
|
45 | + : $this->prepend.$this->getValue(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function setFullUrl(string $fullUrl) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'baseUrlSegment' => $this->baseUrlSegment, |
95 | 95 | 'hint' => null, // Hint placeholder to show url hint when it already exists |
96 | 96 | 'is_homepage' => ($this->getValue() === '/'), |
97 | - 'show' => !!$this->getValue(),// show input field or not |
|
97 | + 'show' => !!$this->getValue(), // show input field or not |
|
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->first(); |
38 | 38 | |
39 | 39 | if (!$record) { |
40 | - throw new UrlRecordNotFound('No url record found by slug [' . $slug . '] for locale [' . $locale . '].'); |
|
40 | + throw new UrlRecordNotFound('No url record found by slug ['.$slug.'] for locale ['.$locale.'].'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $record; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ->first(); |
62 | 62 | |
63 | 63 | if (!$record) { |
64 | - throw new UrlRecordNotFound('No url record found for model [' . $model->getMorphClass() . '@' . $model->id . '] for locale [' . $locale . '].'); |
|
64 | + throw new UrlRecordNotFound('No url record found for model ['.$model->getMorphClass().'@'.$model->id.'] for locale ['.$locale.'].'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $record; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | if ($ignoredModel) { |
158 | - $builder->whereNotIn('id', function ($query) use ($ignoredModel) { |
|
158 | + $builder->whereNotIn('id', function($query) use ($ignoredModel) { |
|
159 | 159 | $query->select('id') |
160 | 160 | ->from('chief_urls') |
161 | 161 | ->where('model_type', '=', $ignoredModel->getMorphClass()) |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | |
176 | 176 | // Filter out offline urls... TODO: this should be a state that is owned by the url and not the model. |
177 | 177 | // Because of archived pages the mapping can be null so we reject them before we check for online |
178 | - return $records->map(function (UrlRecord $urlRecord) { |
|
178 | + return $records->map(function(UrlRecord $urlRecord) { |
|
179 | 179 | return Morphables::instance($urlRecord->model_type)->find($urlRecord->model_id); |
180 | - })->reject(function ($model) { |
|
180 | + })->reject(function($model) { |
|
181 | 181 | return $model == null; |
182 | - })->reject(function (ProvidesUrl $model) { |
|
182 | + })->reject(function(ProvidesUrl $model) { |
|
183 | 183 | return (method_exists($model, 'isPublished') && !$model->isPublished()); |
184 | 184 | }); |
185 | 185 | } |
@@ -60,6 +60,6 @@ |
||
60 | 60 | */ |
61 | 61 | public function message() |
62 | 62 | { |
63 | - return 'De \'' . $this->failedDetails['slug'] . '\' link wordt in het ' . $this->failedDetails['locale'] . ' al door een andere pagina gebruikt.'; |
|
63 | + return 'De \''.$this->failedDetails['slug'].'\' link wordt in het '.$this->failedDetails['locale'].' al door een andere pagina gebruikt.'; |
|
64 | 64 | } |
65 | 65 | } |
@@ -35,6 +35,6 @@ |
||
35 | 35 | /** @inheritdoc */ |
36 | 36 | public function baseUrlSegment(string $locale = null): string |
37 | 37 | { |
38 | - return BaseUrlSegment::find(isset(static::$baseUrlSegment) ? (array) static::$baseUrlSegment : [], $locale); |
|
38 | + return BaseUrlSegment::find(isset(static::$baseUrlSegment) ? (array)static::$baseUrlSegment : [], $locale); |
|
39 | 39 | } |
40 | 40 | } |