@@ -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\Fields\Types; |
6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | return $this; |
41 | 41 | } |
42 | 42 | |
43 | - return 'files['. ($this->values['name'] ?? $this->key()).']'; |
|
43 | + return 'files['.($this->values['name'] ?? $this->key()).']'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function getFieldValue(Model $model, $locale = null) |
@@ -44,7 +44,7 @@ |
||
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 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | throw new \DomainException('Corrupt target model for this url request. Model by reference ['.$urlRecord->model_type.'@'.$urlRecord->model_id.'] has probably been archived or deleted.'); |
45 | 45 | } |
46 | 46 | |
47 | - if (method_exists($model, 'isPublished') && ! $model->isPublished()) { |
|
47 | + if (method_exists($model, 'isPublished') && !$model->isPublished()) { |
|
48 | 48 | |
49 | 49 | /** When admin is logged in and this request is in preview mode, we allow the view */ |
50 | - if (! PreviewMode::fromRequest()->check()) { |
|
51 | - throw new NotFoundHttpException('Model found for request ['. $slug .'] but it is not published.'); |
|
50 | + if (!PreviewMode::fromRequest()->check()) { |
|
51 | + throw new NotFoundHttpException('Model found for request ['.$slug.'] but it is not published.'); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - throw new NotFoundHttpException('No url or model found for request ['. $slug .'] for locale ['.$locale.'].'); |
|
62 | + throw new NotFoundHttpException('No url or model found for request ['.$slug.'] for locale ['.$locale.'].'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | private static function createRedirect(string $url) |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private static function onlineModels(bool $onlySingles = false, Model $ignoredModel = null): Collection |
41 | 41 | { |
42 | - $models = chiefMemoize('all-online-models', function () use ($onlySingles) { |
|
42 | + $models = chiefMemoize('all-online-models', function() use ($onlySingles) { |
|
43 | 43 | $builder = UrlRecord::whereNull('redirect_id') |
44 | 44 | ->select('model_type', 'model_id') |
45 | 45 | ->groupBy('model_type', 'model_id'); |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | $builder->where('model_type', 'singles'); |
49 | 49 | } |
50 | 50 | |
51 | - return $builder->get()->mapToGroups(function ($record) { |
|
51 | + return $builder->get()->mapToGroups(function($record) { |
|
52 | 52 | return [$record->model_type => $record->model_id]; |
53 | - })->map(function ($record, $key) { |
|
53 | + })->map(function($record, $key) { |
|
54 | 54 | return Morphables::instance($key)->find($record->toArray()); |
55 | - })->map->reject(function ($model) { |
|
55 | + })->map->reject(function($model) { |
|
56 | 56 | return is_null($model) || !$model->isPublished(); // Invalid references to archived or removed models where url record still exists. |
57 | 57 | })->flatten(); |
58 | 58 | }, [$onlySingles]); |
59 | 59 | |
60 | 60 | if ($ignoredModel) { |
61 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
61 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
62 | 62 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
63 | 63 | }); |
64 | 64 | } |