From 50c78602f0168b9c0e9887938ff191a80efe401d Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 20 Dec 2021 22:03:46 -0600 Subject: [PATCH 01/23] Run `scout:import` on agents hourly [API-231, API-232] --- app/Console/Kernel.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0cdf3a92..bc783250 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -78,6 +78,14 @@ protected function schedule(Schedule $schedule) ->withoutOverlapping(self::FOR_ONE_YEAR) ->sendOutputTo(storage_path('logs/import-queues-last-run.log')); + // API-231, API-232: Temporary remediation! Artworks can't touch artists. + $schedule->command('scout:import', [ + 'model' => \App\Models\Collections\Agent::class, + ]) + ->hourly() + ->withoutOverlapping(self::FOR_ONE_YEAR) + ->sendOutputTo(storage_path('logs/scout-import-agents-last-run.log')); + if (env('DUMP_SCHEDULE_ENABLED', false)) { $schedule->command('dump:schedule') ->weekly() From d1d2deec233361a28fe620c876bbc814bc3b9c8c Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Tue, 21 Dec 2021 00:10:06 -0600 Subject: [PATCH 02/23] Fix `scout:import` schedule for agents [API-231, API-232] --- app/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index bc783250..a3ec9f09 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -80,7 +80,7 @@ protected function schedule(Schedule $schedule) // API-231, API-232: Temporary remediation! Artworks can't touch artists. $schedule->command('scout:import', [ - 'model' => \App\Models\Collections\Agent::class, + \App\Models\Collections\Agent::class, ]) ->hourly() ->withoutOverlapping(self::FOR_ONE_YEAR) From b1d60158a32cb0adc3d0550dbe4a00f80f702a7c Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Tue, 21 Dec 2021 00:17:11 -0600 Subject: [PATCH 03/23] Include artists with one artwork in autosuggest [API-231] --- app/Transformers/Outbound/Collections/Agent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Transformers/Outbound/Collections/Agent.php b/app/Transformers/Outbound/Collections/Agent.php index 2a16c7f0..bf5c82cc 100644 --- a/app/Transformers/Outbound/Collections/Agent.php +++ b/app/Transformers/Outbound/Collections/Agent.php @@ -183,7 +183,7 @@ protected function getSuggestFields() $suggestFields = $this->traitGetSuggestFields(); $newFilter = function ($item) { - return $item->createdArtworks()->count() > 1; + return $item->createdArtworks()->count() > 0; }; foreach (['suggest_autocomplete_all', 'suggest_autocomplete_boosted'] as $fieldName) { From 77ab10016b2e0608e047bcd6e214cafc686e1a86 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Tue, 4 Jan 2022 12:36:17 -0600 Subject: [PATCH 04/23] Filter `null` from artist `alt_titles` for autosuggest [API-234] --- app/Transformers/Outbound/Collections/Agent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Transformers/Outbound/Collections/Agent.php b/app/Transformers/Outbound/Collections/Agent.php index bf5c82cc..875e6af6 100644 --- a/app/Transformers/Outbound/Collections/Agent.php +++ b/app/Transformers/Outbound/Collections/Agent.php @@ -200,7 +200,7 @@ protected function getSuggestFields() $item->title, $item->sort_title, ], - $item->alt_titles ?? [] + array_filter($item->alt_titles ?? []) ), 'weight' => $item->isBoosted() ? 3 : 2, ]; @@ -213,7 +213,7 @@ protected function getSuggestFields() $item->title, $item->sort_title, ], - $item->alt_titles ?? [] + array_filter($item->alt_titles ?? []) ), 'weight' => $item->isBoosted() ? 3 : 2, 'contexts' => [ From 574f5ea64037c4e3e1912431b44fa2f5316883f1 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Fri, 7 Jan 2022 15:05:32 -0600 Subject: [PATCH 05/23] Add `config` block to search responses [API-237] --- app/Http/Search/Response.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Search/Response.php b/app/Http/Search/Response.php index 8f3dc247..b0051587 100644 --- a/app/Http/Search/Response.php +++ b/app/Http/Search/Response.php @@ -84,6 +84,12 @@ public function getSearchResponse() $response ); + $config = config('aic.config_documentation'); + + if ($config) { + $response['config'] = $config; + } + return $response; } From 99a8f5530263a601d7525926c36be164139fde37 Mon Sep 17 00:00:00 2001 From: nikhiltri Date: Mon, 15 Nov 2021 16:19:40 -0600 Subject: [PATCH 06/23] Disable fuzzy search on exact match searches [ART-44] --- app/Http/Search/Request.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Http/Search/Request.php b/app/Http/Search/Request.php index faccd1f5..47ad40c5 100644 --- a/app/Http/Search/Request.php +++ b/app/Http/Search/Request.php @@ -910,6 +910,11 @@ private function getFuzzy(array $input, string $query = null) return 0; } + // Disable fuzzy search on exact match searches + if (count(explode('"', $query ?? $input['q'] ?? '')) > 1) { + return 0; + } + if (!isset($input['fuzzy'])) { return 'AUTO'; } From 057f2c59869662eeacc0b81ca01acae9a119d7f5 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 5 Jan 2022 17:16:30 -0600 Subject: [PATCH 07/23] Add `name` analyzer for artist names [ART-44] --- .../Outbound/AbstractTransformer.php | 16 ++++++++++++++ .../Outbound/Collections/Agent.php | 21 ++++++++++++++++--- .../Outbound/Collections/Artwork.php | 13 +++++++++++- config/elasticsearch.php | 9 ++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/app/Transformers/Outbound/AbstractTransformer.php b/app/Transformers/Outbound/AbstractTransformer.php index 62f397b3..cd76355e 100644 --- a/app/Transformers/Outbound/AbstractTransformer.php +++ b/app/Transformers/Outbound/AbstractTransformer.php @@ -344,6 +344,22 @@ protected function getEmptyValue($fieldName) }; } + /** + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html + */ + protected function getDefaultStringMapping($customMapping) + { + return array_merge_recursive($customMapping, [ + 'type' => 'text', + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + 'ignore_above' => 256, + ], + ], + ]); + } + /** * Helper to parse out the fields variable passed via constructor. * Expects a comma-separated string or an array. diff --git a/app/Transformers/Outbound/Collections/Agent.php b/app/Transformers/Outbound/Collections/Agent.php index 875e6af6..28e86009 100644 --- a/app/Transformers/Outbound/Collections/Agent.php +++ b/app/Transformers/Outbound/Collections/Agent.php @@ -35,18 +35,33 @@ public function includePlacePivots($agent) protected function getTitles() { - return array_merge(parent::getTitles(), [ + $baseTitle = parent::getTitles(); + + $baseTitle['title']['elasticsearch']['mapping'] = $this->getDefaultStringMapping([ + 'analyzer' => 'name', + ]); + + return array_merge($baseTitle, [ 'sort_title' => [ 'doc' => 'Sortable name for this agent, typically with last name first.', 'type' => 'string', - 'elasticsearch' => 'text', + 'elasticsearch' => [ + 'mapping' => [ + 'type' => 'text', + 'analyzer' => 'name', + ], + ], ], 'alt_titles' => [ 'doc' => 'Alternate names for this agent', 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', + + 'mapping' => [ + 'type' => 'text', + 'analyzer' => 'name', + ], // For better search experiences with Korean, Chinese and Japanese queries. // See https://www.elastic.co/blog/how-to-search-ch-jp-kr-part-2 diff --git a/app/Transformers/Outbound/Collections/Artwork.php b/app/Transformers/Outbound/Collections/Artwork.php index 869395c4..364ad8d6 100644 --- a/app/Transformers/Outbound/Collections/Artwork.php +++ b/app/Transformers/Outbound/Collections/Artwork.php @@ -196,7 +196,10 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', + 'mapping' => [ + 'type' => 'text', + 'analyzer' => 'name', + ], ], ], 'place_of_origin' => [ @@ -475,6 +478,11 @@ protected function getFields() 'artist_title' => [ 'doc' => 'Name of the preferred artist/culture associated with this work', 'type' => 'string', + 'elasticsearch' => [ + 'mapping' => $this->getDefaultStringMapping([ + 'analyzer' => 'name', + ]), + ], 'value' => function ($item) { return $item->artist->title ?? null; }, @@ -502,6 +510,9 @@ protected function getFields() 'default' => true, // This is controllable via .env so we can tweak it without pushing to prod 'boost' => (float) (env('SEARCH_BOOST_ARTIST_TITLES') ?: 2), + 'mapping' => $this->getDefaultStringMapping([ + 'analyzer' => 'name', + ]), ], 'value' => function ($item) { return $item->artists->pluck('title'); diff --git a/config/elasticsearch.php b/config/elasticsearch.php index 2d364379..f137e7a2 100644 --- a/config/elasticsearch.php +++ b/config/elasticsearch.php @@ -282,6 +282,15 @@ 'asciifolding', ], ], + 'name' => [ + 'tokenizer' => 'standard', + 'filter' => [ + 'lowercase', + 'english_stop', + 'asciifolding', + 'shingle', + ], + ], ], ], ], From d74e5f40af89eb9b428b10ef3085a64e6571cc3d Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 5 Jan 2022 17:17:58 -0600 Subject: [PATCH 08/23] Make `search:reindex` synchronous [ART-44] --- app/Console/Commands/Search/SearchReindex.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Search/SearchReindex.php b/app/Console/Commands/Search/SearchReindex.php index 96bfeddf..7a761ce3 100644 --- a/app/Console/Commands/Search/SearchReindex.php +++ b/app/Console/Commands/Search/SearchReindex.php @@ -45,7 +45,7 @@ public function reindex($model) $index = app('Search')->getIndexForModel($model, $this->source); $params = [ - 'wait_for_completion' => false, + 'wait_for_completion' => true, 'body' => [ 'source' => [ 'index' => $index, @@ -58,8 +58,10 @@ public function reindex($model) ], ]; + $this->warn('Reindex from ' . $index . ' is starting...'); + $return = Elasticsearch::reindex($params); - $this->info('Reindex from ' . $index . ' has started. Monitor the process here: ' . $this->baseUrl() . '/_tasks/' . $return['task']); + $this->info('Reindex from ' . $index . ' has finished.'); } } From 596b518f84db8681291dfcbf633ca44a23091d54 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 02:45:52 -0600 Subject: [PATCH 09/23] Add `exact` subfield to all default fields [ART-44] --- app/Http/Search/Request.php | 7 ++-- app/Models/ElasticSearchable.php | 8 +++- .../Outbound/AbstractTransformer.php | 38 ++++++++++++++++--- .../Outbound/Collections/Agent.php | 11 ------ .../Outbound/Collections/Artwork.php | 20 +++------- .../Outbound/Collections/Exhibition.php | 1 - app/Transformers/Outbound/Dsc/Section.php | 1 - app/Transformers/Outbound/Mobile/Sound.php | 2 - app/Transformers/Outbound/Mobile/Tour.php | 4 +- app/Transformers/Outbound/Mobile/TourStop.php | 1 - app/Transformers/Outbound/Shop/Product.php | 1 - .../Outbound/StaticArchive/Site.php | 3 -- app/Transformers/Outbound/Web/Article.php | 1 - .../Web/DigitalPublicationSection.php | 1 - app/Transformers/Outbound/Web/Event.php | 2 - .../Outbound/Web/EventOccurrence.php | 1 - app/Transformers/Outbound/Web/Highlight.php | 1 - app/Transformers/Outbound/Web/Page.php | 1 - .../Outbound/Web/Traits/HasSearchTags.php | 1 - config/elasticsearch.php | 2 +- 20 files changed, 50 insertions(+), 57 deletions(-) diff --git a/app/Http/Search/Request.php b/app/Http/Search/Request.php index 47ad40c5..b93bf97a 100644 --- a/app/Http/Search/Request.php +++ b/app/Http/Search/Request.php @@ -751,6 +751,7 @@ private function addSimpleSearchParams(array $params, array $input) foreach ($withQuotes as $subquery) { $params['body']['query']['bool']['must'][] = [ 'multi_match' => [ + 'analyzer' => 'exact', 'query' => str_replace('"', '', $subquery), 'fields' => $exactFields, 'type' => 'phrase', @@ -760,7 +761,7 @@ private function addSimpleSearchParams(array $params, array $input) } // Determing if fuzzy searching should be used on this query - $fuzziness = $this->getFuzzy($input, $input['q']); + $fuzziness = $this->getFuzzy($input, $input['q'], count($withQuotes) > 0); foreach ($withoutQuotes as $subquery) { // Pull all docs that match fuzzily into the results @@ -904,14 +905,14 @@ public function addAggregationParams(array $params, array $input) return $params; } - private function getFuzzy(array $input, string $query = null) + private function getFuzzy(array $input, string $query = null, $isExact = false) { if (count(explode(' ', $query ?? $input['q'] ?? '')) > 7) { return 0; } // Disable fuzzy search on exact match searches - if (count(explode('"', $query ?? $input['q'] ?? '')) > 1) { + if ($isExact) { return 0; } diff --git a/app/Models/ElasticSearchable.php b/app/Models/ElasticSearchable.php index dc3d12a3..6ee34a55 100644 --- a/app/Models/ElasticSearchable.php +++ b/app/Models/ElasticSearchable.php @@ -96,6 +96,7 @@ public function getDefaultSearchFieldMapping($isExact) /** * Return names of fields marked as default, for simple search. * This method appends a boost factor to the field name, if present. + * ART-44: Targets `exact` subfield, if present in `mapping`. * * ```php * [ @@ -103,7 +104,6 @@ public function getDefaultSearchFieldMapping($isExact) * 'elasticsearch' => [ * 'default' => true, * 'boost' => 3, - * 'type' => 'text', * ] * ], * ``` @@ -116,10 +116,14 @@ public function getDefaultSearchFields($isExact) { $fields = $this->getDefaultSearchFieldMapping($isExact); - $fields = array_map(function ($field) { + $fields = array_map(function ($field) use ($isExact) { $label = $field['name']; + if ($isExact && isset($field['elasticsearch']['mapping']['fields']['exact'])) { + $label .= '.exact'; + } + if (isset($field['elasticsearch']['boost'])) { $label .= '^' . $field['elasticsearch']['boost']; } diff --git a/app/Transformers/Outbound/AbstractTransformer.php b/app/Transformers/Outbound/AbstractTransformer.php index cd76355e..a456db3d 100644 --- a/app/Transformers/Outbound/AbstractTransformer.php +++ b/app/Transformers/Outbound/AbstractTransformer.php @@ -345,19 +345,38 @@ protected function getEmptyValue($fieldName) } /** + * ART-44: Support exact matching for quoted text + * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html */ - protected function getDefaultStringMapping($customMapping) + protected function getDefaultStringMapping($hasKeyword = false, $customMapping = []) { - return array_merge_recursive($customMapping, [ + $mapping = [ 'type' => 'text', 'fields' => [ - 'keyword' => [ - 'type' => 'keyword', - 'ignore_above' => 256, + 'exact' => [ + 'type' => 'text', + 'analyzer' => 'exact', ], ], - ]); + ]; + + if ($hasKeyword) { + $mapping = array_merge_recursive($mapping, [ + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + 'ignore_above' => 256, + ], + ], + ]); + } + + if ($customMapping) { + $mapping = array_merge_recursive($mapping, $customMapping); + } + + return $mapping; } /** @@ -404,6 +423,13 @@ private function initMappedFields() } foreach ($mappedFields as $fieldName => $mappedField) { + // ART-44: Add `exact` subfield to default fields with undefined mapping + if ($mappedField['elasticsearch']['default'] ?? false) { + if (!isset($mappedField['elasticsearch']['mapping'])) { + $mappedFields[$fieldName]['elasticsearch']['mapping'] = $this->getDefaultStringMapping(); + } + } + if (!isset($mappedFields[$fieldName]['value'])) { $mappedFields[$fieldName]['value'] = function ($model) use ($fieldName) { return $model->{$fieldName}; diff --git a/app/Transformers/Outbound/Collections/Agent.php b/app/Transformers/Outbound/Collections/Agent.php index 28e86009..7b9bab5d 100644 --- a/app/Transformers/Outbound/Collections/Agent.php +++ b/app/Transformers/Outbound/Collections/Agent.php @@ -45,12 +45,6 @@ protected function getTitles() 'sort_title' => [ 'doc' => 'Sortable name for this agent, typically with last name first.', 'type' => 'string', - 'elasticsearch' => [ - 'mapping' => [ - 'type' => 'text', - 'analyzer' => 'name', - ], - ], ], 'alt_titles' => [ 'doc' => 'Alternate names for this agent', @@ -58,11 +52,6 @@ protected function getTitles() 'elasticsearch' => [ 'default' => true, - 'mapping' => [ - 'type' => 'text', - 'analyzer' => 'name', - ], - // For better search experiences with Korean, Chinese and Japanese queries. // See https://www.elastic.co/blog/how-to-search-ch-jp-kr-part-2 'fields' => [ diff --git a/app/Transformers/Outbound/Collections/Artwork.php b/app/Transformers/Outbound/Collections/Artwork.php index 364ad8d6..a4e659a8 100644 --- a/app/Transformers/Outbound/Collections/Artwork.php +++ b/app/Transformers/Outbound/Collections/Artwork.php @@ -68,7 +68,6 @@ protected function getTitles() 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]); @@ -112,8 +111,10 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, + 'mapping' => [ + 'type' => 'keyword', + ], 'boost' => 5, - 'type' => 'keyword', ], 'value' => function ($item) { return $item->main_id; @@ -172,7 +173,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'date_qualifier_title' => [ @@ -196,10 +196,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'mapping' => [ - 'type' => 'text', - 'analyzer' => 'name', - ], ], ], 'place_of_origin' => [ @@ -225,7 +221,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'inscriptions' => [ @@ -238,7 +233,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'publication_history' => [ @@ -479,9 +473,7 @@ protected function getFields() 'doc' => 'Name of the preferred artist/culture associated with this work', 'type' => 'string', 'elasticsearch' => [ - 'mapping' => $this->getDefaultStringMapping([ - 'analyzer' => 'name', - ]), + 'mapping' => $this->getDefaultStringMapping(true), ], 'value' => function ($item) { return $item->artist->title ?? null; @@ -508,11 +500,9 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, + 'mapping' => $this->getDefaultStringMapping(true), // This is controllable via .env so we can tweak it without pushing to prod 'boost' => (float) (env('SEARCH_BOOST_ARTIST_TITLES') ?: 2), - 'mapping' => $this->getDefaultStringMapping([ - 'analyzer' => 'name', - ]), ], 'value' => function ($item) { return $item->artists->pluck('title'); diff --git a/app/Transformers/Outbound/Collections/Exhibition.php b/app/Transformers/Outbound/Collections/Exhibition.php index ffa70e5b..3ee0872c 100644 --- a/app/Transformers/Outbound/Collections/Exhibition.php +++ b/app/Transformers/Outbound/Collections/Exhibition.php @@ -58,7 +58,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'short_description' => [ diff --git a/app/Transformers/Outbound/Dsc/Section.php b/app/Transformers/Outbound/Dsc/Section.php index 2a9473a1..02a89665 100644 --- a/app/Transformers/Outbound/Dsc/Section.php +++ b/app/Transformers/Outbound/Dsc/Section.php @@ -91,7 +91,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]; diff --git a/app/Transformers/Outbound/Mobile/Sound.php b/app/Transformers/Outbound/Mobile/Sound.php index ccedbed9..a7d866b6 100644 --- a/app/Transformers/Outbound/Mobile/Sound.php +++ b/app/Transformers/Outbound/Mobile/Sound.php @@ -15,7 +15,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { $title = summation($item->artworks->pluck('title')->all()); @@ -46,7 +45,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]; diff --git a/app/Transformers/Outbound/Mobile/Tour.php b/app/Transformers/Outbound/Mobile/Tour.php index e60688ab..37b17434 100644 --- a/app/Transformers/Outbound/Mobile/Tour.php +++ b/app/Transformers/Outbound/Mobile/Tour.php @@ -40,7 +40,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { return $item->intro_text; @@ -64,7 +63,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { return $item->intro->transcript ?? null; @@ -75,6 +73,7 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, + 'mapping' => $this->getDefaultStringMapping(true), ], 'value' => function ($item) { return $item->tourStops->pluck('artwork')->pluck('artwork')->pluck('title')->filter()->values(); @@ -85,6 +84,7 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, + 'mapping' => $this->getDefaultStringMapping(true), ], 'value' => function ($item) { return $item->tourStops->pluck('artwork')->pluck('artwork')->pluck('artists')->collapse()->pluck('title'); diff --git a/app/Transformers/Outbound/Mobile/TourStop.php b/app/Transformers/Outbound/Mobile/TourStop.php index 67f93b99..d8d12e72 100644 --- a/app/Transformers/Outbound/Mobile/TourStop.php +++ b/app/Transformers/Outbound/Mobile/TourStop.php @@ -30,7 +30,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { return $item->sound->transcript ?? null; diff --git a/app/Transformers/Outbound/Shop/Product.php b/app/Transformers/Outbound/Shop/Product.php index e1aaeba2..70dd08fb 100644 --- a/app/Transformers/Outbound/Shop/Product.php +++ b/app/Transformers/Outbound/Shop/Product.php @@ -36,7 +36,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'price_display' => [ diff --git a/app/Transformers/Outbound/StaticArchive/Site.php b/app/Transformers/Outbound/StaticArchive/Site.php index 657bbc74..b6b27e46 100644 --- a/app/Transformers/Outbound/StaticArchive/Site.php +++ b/app/Transformers/Outbound/StaticArchive/Site.php @@ -24,7 +24,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'web_url' => [ @@ -47,7 +46,6 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { return $item->exhibitions->pluck('title'); @@ -81,7 +79,6 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { return $item->artworks->pluck('title'); diff --git a/app/Transformers/Outbound/Web/Article.php b/app/Transformers/Outbound/Web/Article.php index 18aba878..2382876b 100644 --- a/app/Transformers/Outbound/Web/Article.php +++ b/app/Transformers/Outbound/Web/Article.php @@ -36,7 +36,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]; diff --git a/app/Transformers/Outbound/Web/DigitalPublicationSection.php b/app/Transformers/Outbound/Web/DigitalPublicationSection.php index d6c03eb7..ade0b6f3 100644 --- a/app/Transformers/Outbound/Web/DigitalPublicationSection.php +++ b/app/Transformers/Outbound/Web/DigitalPublicationSection.php @@ -46,7 +46,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], // TODO: This seems to always be null. Remove? diff --git a/app/Transformers/Outbound/Web/Event.php b/app/Transformers/Outbound/Web/Event.php index e70faec7..684e57d6 100644 --- a/app/Transformers/Outbound/Web/Event.php +++ b/app/Transformers/Outbound/Web/Event.php @@ -82,7 +82,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'location' => [ @@ -139,7 +138,6 @@ protected function getFields() 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], 'value' => function ($item) { if ($item->programs) { diff --git a/app/Transformers/Outbound/Web/EventOccurrence.php b/app/Transformers/Outbound/Web/EventOccurrence.php index 8332560e..b67dec17 100644 --- a/app/Transformers/Outbound/Web/EventOccurrence.php +++ b/app/Transformers/Outbound/Web/EventOccurrence.php @@ -32,7 +32,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'image_url' => [ diff --git a/app/Transformers/Outbound/Web/Highlight.php b/app/Transformers/Outbound/Web/Highlight.php index b5192f00..b8cab076 100644 --- a/app/Transformers/Outbound/Web/Highlight.php +++ b/app/Transformers/Outbound/Web/Highlight.php @@ -31,7 +31,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]; diff --git a/app/Transformers/Outbound/Web/Page.php b/app/Transformers/Outbound/Web/Page.php index c8cdd85a..674f6c8b 100644 --- a/app/Transformers/Outbound/Web/Page.php +++ b/app/Transformers/Outbound/Web/Page.php @@ -67,7 +67,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], ]; diff --git a/app/Transformers/Outbound/Web/Traits/HasSearchTags.php b/app/Transformers/Outbound/Web/Traits/HasSearchTags.php index 978d909f..c545dafe 100644 --- a/app/Transformers/Outbound/Web/Traits/HasSearchTags.php +++ b/app/Transformers/Outbound/Web/Traits/HasSearchTags.php @@ -14,7 +14,6 @@ protected function getFieldsForHasSearchTags() 'elasticsearch' => [ 'default' => true, 'boost' => 5, - 'type' => 'text', ], 'value' => function ($item) { if (!$item->search_tags) { diff --git a/config/elasticsearch.php b/config/elasticsearch.php index f137e7a2..17a2aeb2 100644 --- a/config/elasticsearch.php +++ b/config/elasticsearch.php @@ -282,7 +282,7 @@ 'asciifolding', ], ], - 'name' => [ + 'exact' => [ 'tokenizer' => 'standard', 'filter' => [ 'lowercase', From 994a44bff47f526d2f7488130129ab6c09934824 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 02:46:48 -0600 Subject: [PATCH 10/23] Make `search:reindex` asynchronous again [ART-44] --- app/Console/Commands/Search/SearchReindex.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/Search/SearchReindex.php b/app/Console/Commands/Search/SearchReindex.php index 7a761ce3..96bfeddf 100644 --- a/app/Console/Commands/Search/SearchReindex.php +++ b/app/Console/Commands/Search/SearchReindex.php @@ -45,7 +45,7 @@ public function reindex($model) $index = app('Search')->getIndexForModel($model, $this->source); $params = [ - 'wait_for_completion' => true, + 'wait_for_completion' => false, 'body' => [ 'source' => [ 'index' => $index, @@ -58,10 +58,8 @@ public function reindex($model) ], ]; - $this->warn('Reindex from ' . $index . ' is starting...'); - $return = Elasticsearch::reindex($params); - $this->info('Reindex from ' . $index . ' has finished.'); + $this->info('Reindex from ' . $index . ' has started. Monitor the process here: ' . $this->baseUrl() . '/_tasks/' . $return['task']); } } From 2ead01d8f40363ac429cce43734b4155a6f1f49c Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 10:56:52 -0600 Subject: [PATCH 11/23] Limit when proximity phrase query gets applied [ART-44] --- app/Http/Search/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Search/Request.php b/app/Http/Search/Request.php index b93bf97a..09fbbcbd 100644 --- a/app/Http/Search/Request.php +++ b/app/Http/Search/Request.php @@ -794,7 +794,7 @@ private function addSimpleSearchParams(array $params, array $input) // This boosts docs that have multiple terms in close proximity // `phrase` queries are relatively expensive, so check for spaces first // https://www.elastic.co/guide/en/elasticsearch/guide/current/_improving_performance.html - if (strpos($input['q'], ' ')) { + if ((count($withoutQuotes) > 0 || count($withQuotes) > 1) && strpos($input['q'], ' ')) { $params['body']['query']['bool']['should'][] = [ 'multi_match' => [ 'query' => str_replace('"', '', $input['q']), From 9529ea6042dd7646f757cdaea608a055b50c1763 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 10:57:08 -0600 Subject: [PATCH 12/23] Ensure `title` has `keyword` subfield [ART-44] --- app/Transformers/Outbound/AbstractTransformer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Transformers/Outbound/AbstractTransformer.php b/app/Transformers/Outbound/AbstractTransformer.php index a456db3d..e942ddf0 100644 --- a/app/Transformers/Outbound/AbstractTransformer.php +++ b/app/Transformers/Outbound/AbstractTransformer.php @@ -170,6 +170,7 @@ protected function getTitles() 'type' => 'string', 'elasticsearch' => [ 'default' => true, + 'mapping' => $this->getDefaultStringMapping(true), 'boost' => 1.5, ], ], From 58f45cdeb45c1a29deff816f815b692cc15fb53d Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 11:24:22 -0600 Subject: [PATCH 13/23] Change `main_reference_number` to `text` [ART-44] --- app/Transformers/Outbound/Collections/Artwork.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Transformers/Outbound/Collections/Artwork.php b/app/Transformers/Outbound/Collections/Artwork.php index a4e659a8..37185288 100644 --- a/app/Transformers/Outbound/Collections/Artwork.php +++ b/app/Transformers/Outbound/Collections/Artwork.php @@ -111,9 +111,7 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'mapping' => [ - 'type' => 'keyword', - ], + 'mapping' => $this->getDefaultStringMapping(true), 'boost' => 5, ], 'value' => function ($item) { From 508a4e81baaec1b139f50ed8139d789655573355 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Mon, 10 Jan 2022 11:52:21 -0600 Subject: [PATCH 14/23] Import `place_of_origin_id` for artworks [API-235] --- .../Inbound/Collections/Artwork.php | 18 +++++++++++++++++- .../Outbound/Collections/Artwork.php | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Transformers/Inbound/Collections/Artwork.php b/app/Transformers/Inbound/Collections/Artwork.php index ba219a20..611b116b 100644 --- a/app/Transformers/Inbound/Collections/Artwork.php +++ b/app/Transformers/Inbound/Collections/Artwork.php @@ -161,12 +161,28 @@ private function getSyncArtists(Datum $datum) /** * Attach artwork places, and what happened to the artwork in each place. * - * @TODO Waiting on Redmine #2847 – place normalization for non-"Web Everything" works + * API-235, API-204: Place normalization for non-"Web Everything" artworks * * @return array */ private function getSyncPlaces(Datum $datum) { + // Worst case: no pivots, nor basic place + if (!$datum->artwork_places && !$datum->place_of_origin_id) { + return []; + } + + // No pivots, but basic place + if (!$datum->artwork_places && $datum->place_of_origin_id) { + // Default `artwork_place_qualifier_citi_id` to 3 (Object made in) + return [ + $datum->place_of_origin_id => [ + 'artwork_place_qualifier_citi_id' => 3, + 'preferred' => true, + ], + ]; + } + return $this->getSyncPivots($datum, 'artwork_places', 'place_id', function ($pivot) { return [ $pivot->place_id => [ diff --git a/app/Transformers/Outbound/Collections/Artwork.php b/app/Transformers/Outbound/Collections/Artwork.php index 37185288..79e0f248 100644 --- a/app/Transformers/Outbound/Collections/Artwork.php +++ b/app/Transformers/Outbound/Collections/Artwork.php @@ -202,6 +202,8 @@ protected function getFields() 'elasticsearch' => [ 'default' => true, ], + // API-235: Pull this from related place? For now, leaving as-is for performance. + // API-204: Eventually, this should be an array of all ancestor place names. ], 'description' => [ 'doc' => 'Longer explanation describing the work', From 81a864e323b9715b409743b7e3a8420c57b10482 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 2 Feb 2022 21:36:42 -0600 Subject: [PATCH 15/23] Do not cache Elasticsearch results [API-255] --- .env.example | 4 -- app/Http/Controllers/SearchController.php | 47 +---------------------- config/elasticsearch.php | 5 --- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/.env.example b/.env.example index a3605247..f01f0278 100644 --- a/.env.example +++ b/.env.example @@ -45,10 +45,6 @@ ELASTICSEARCH_HOST='localhost' ELASTICSEARCH_PORT=9200 ELASTICSEARCH_SCHEME='http' -ELASTICSEARCH_CACHE_ENABLED=false -ELASTICSEARCH_CACHE_TTL=1800 # 30 min -ELASTICSEARCH_CACHE_VERSION='v1' - # https://aws.amazon.com/blogs/database/get-started-with-amazon-elasticsearch-service-how-many-shards-do-i-need/ ELASTICSEARCH_SHARDS_PRIMARY=1 # Increase if average index size is greater than 30 GB ELASTICSEARCH_SHARDS_REPLICA=0 # Set to number of nodes - 1 diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 073477eb..0b8ad606 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -30,20 +30,6 @@ class SearchController extends BaseController | */ - private $useCache; - - public function __construct() - { - $this->useCache = config('elasticsearch.cache_enabled'); - - $cacheParam = RequestFacade::input('cache'); - $cacheParam = !is_string($cacheParam) ? $cacheParam : filter_var($cacheParam, FILTER_VALIDATE_BOOLEAN); - - if ($this->useCache && $cacheParam === false && Gate::allows('restricted-access')) { - $this->useCache = false; - } - } - /** * General entry point for search. There are three modes: * @@ -140,11 +126,6 @@ public function echo(Request $request, $resource = null) return response($this->getRequest())->header('Content-Type', 'application/json'); } - protected function buildCacheKey() - { - return md5(json_encode(func_get_args())); - } - /** * Helper method to perform a query against Elasticsearch endpoint. * @@ -164,26 +145,14 @@ private function query($requestMethod, $responseMethod, $elasticsearchMethod, $r // Transform our API's syntax into an Elasticsearch params array $params = ( new SearchRequest($resource, $id) )->{$requestMethod}($input); - $cacheKey = $this->buildCacheKey($elasticsearchMethod, $params, config('elasticsearch.cache_version')); $results = null; try { - // Perform API request and caching - if ($this->useCache) { - $results = \Cache::remember($cacheKey, config('elasticsearch.cache_ttl'), function () use ($elasticsearchMethod, $params) { - return Elasticsearch::$elasticsearchMethod($params); - }); - } else { - $results = Elasticsearch::$elasticsearchMethod($params); - } + $results = Elasticsearch::$elasticsearchMethod($params); } catch (\Exception $e) { // Elasticsearch occasionally returns a status code of zero $code = $e->getCode() > 0 ? $e->getCode() : 500; - if ($this->useCache) { - \Cache::forget($cacheKey); - } - return response($e->getMessage(), $code)->header('Content-Type', 'application/json'); } @@ -249,26 +218,14 @@ private function mquery($requestMethod, $responseMethod, Request $request, $requ } $params = ['body' => $transformedParams]; - $cacheKey = $this->buildCacheKey('msearch', $params, config('elasticsearch.cache_version')); $results = null; try { - // Perform API request and caching - if ($this->useCache) { - $results = \Cache::remember($cacheKey, config('elasticsearch.cache_ttl'), function () use ($params) { - return Elasticsearch::msearch($params); - }); - } else { - $results = Elasticsearch::msearch($params); - } + $results = Elasticsearch::msearch($params); } catch (\Exception $e) { // Elasticsearch occasionally returns a status code of zero $code = $e->getCode() > 0 ? $e->getCode() : 500; - if ($this->useCache) { - \Cache::forget($cacheKey); - } - return response($e->getMessage(), $code)->header('Content-Type', 'application/json'); } diff --git a/config/elasticsearch.php b/config/elasticsearch.php index 17a2aeb2..221cbc81 100644 --- a/config/elasticsearch.php +++ b/config/elasticsearch.php @@ -299,9 +299,4 @@ ], ], - - 'cache_enabled' => (bool) env('ELASTICSEARCH_CACHE_ENABLED', false), - 'cache_ttl' => env('ELASTICSEARCH_CACHE_TTL', 60 * 30), // Half an hour default - 'cache_version' => env('ELASTICSEARCH_CACHE_VERSION', 1), - ]; From 5527b844931b55135481d4c4c3d1da792508e040 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 2 Feb 2022 23:15:35 -0600 Subject: [PATCH 16/23] Update foundation [API-257] --- .gitignore | 34 +- .php_cs.dist | 363 ------------------- app/Models/AbstractPivot.php | 5 +- app/Models/BaseModel.php | 2 +- app/Models/Instancable.php | 27 -- composer.json | 32 +- composer.lock | 684 +++++++++++++++++++++++++++++++++-- 7 files changed, 703 insertions(+), 444 deletions(-) delete mode 100644 .php_cs.dist delete mode 100644 app/Models/Instancable.php diff --git a/.gitignore b/.gitignore index d0fd065f..03c2d695 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,36 @@ +# Laravel 8.x Defaults /node_modules /public/hot /public/storage /storage/*.key /vendor -/.idea -/.vagrant +.env +.env.backup +.phpunit.result.cache +docker-compose.override.yml Homestead.json Homestead.yaml npm-debug.log -.env* -!.env.*example -!.env.ci -Envoy.blade.php -.phpunit.result.cache -docker-compose.override.yml +yarn-error.log +/.idea +/.vscode + +# Foundation workflow [API-118] +composer-dev.json +composer-dev.lock + +# PHP-CS-Fixer [API-45] .php_cs.cache -.php_cs +.php-cs-fixer.cache +# Custom additions /public/js /public/css - +/public/docs +/.vagrant +.env* +!.env.*example +!.env.ci pids logs coverage/ @@ -30,6 +41,3 @@ dist .basement config.local.js basement_dist -/public/docs -/.idea -/.vscode diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 9d2657ef..00000000 --- a/.php_cs.dist +++ /dev/null @@ -1,363 +0,0 @@ -exclude([ - '.git', - 'bootstrap/cache', - 'database/dumps', // WEB-2013: Obsolete! - 'node_modules', - 'public', - 'resources/lang', - 'storage', - 'vendor', - ]) - ->in(__DIR__) -; - -return PhpCsFixer\Config::create() - ->setIndent(' ') - ->setUsingCache(false) - ->setRules([ - 'align_multiline_comment' => [ - 'comment_type' => 'phpdocs_like', - ], - 'array_indentation' => true, - 'array_syntax' => [ - 'syntax' => 'short', - ], - 'backtick_to_shell_exec' => true, - 'binary_operator_spaces' => [ - 'default' => 'single_space', - ], - 'blank_line_after_namespace' => true, - 'blank_line_after_opening_tag' => true, - 'blank_line_before_statement' => [ - 'statements' => [ - 'for', - 'foreach', - 'if', - 'switch', - 'try', - 'while', - ], - ], - // The `braces` fixer does way too much, not just fix braces: - // https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/823 - // 'braces' => [ - // 'allow_single_line_closure' => false, - // 'position_after_anonymous_constructs' => 'same', - // 'position_after_control_structures' => 'same', - // 'position_after_functions_and_oop_constructs' => 'next', - // ], - 'cast_spaces' => true, - // Also removes lines around class body. For reverse: - // https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3688 - // 'class_attributes_separation' => [ - // 'elements' => [ - // 'const', - // 'method', - // 'property', - // ], - // ], - 'class_definition' => [ - 'multi_line_extends_each_single_line' => true, - 'single_item_single_line' => true, - 'single_line' => false, - ], - 'class_keyword_remove' => false, - 'combine_consecutive_issets' => false, - 'combine_consecutive_unsets' => false, - 'combine_nested_dirname' => true, - 'comment_to_phpdoc' => false, - 'compact_nullable_typehint' => true, - 'concat_space' => [ - 'spacing' => 'one', - ], - 'date_time_immutable' => false, - 'declare_equal_normalize' => [ - 'space' => 'single', - ], - 'declare_strict_types' => false, // ...but consider doing later! - 'dir_constant' => true, - 'elseif' => true, - 'encoding' => true, - 'ereg_to_preg' => true, - 'error_suppression' => false, // Unsure of function - 'escape_implicit_backslashes' => [ - 'double_quoted' => true, - 'heredoc_syntax' => true, - 'single_quoted' => false, // FQCN conflict - ], - 'explicit_indirect_variable' => true, - 'explicit_string_variable' => true, - 'final_class' => false, - 'final_internal_class' => false, - 'fopen_flag_order' => true, - 'fopen_flags' => true, - 'full_opening_tag' => true, - 'fully_qualified_strict_types' => true, - 'function_declaration' => [ - 'closure_function_spacing' => 'one', - ], - 'function_to_constant' => false, // For `get_class` magic - 'function_typehint_space' => true, - // general_phpdoc_annotation_remove - // header_comment - // heredoc_indentation - // heredoc_to_nowdoc - 'implode_call' => false, - 'include' => true, - 'increment_style' => [ - 'style' => 'post', - ], - 'indentation_type' => true, - 'is_null' => false, // ...but consider implementing - 'line_ending' => true, - 'linebreak_after_opening_tag' => true, - 'list_syntax' => [ - 'syntax' => 'short', - ], - 'logical_operators' => true, - 'lowercase_cast' => true, - 'lowercase_constants' => true, - 'lowercase_keywords' => true, - 'lowercase_static_reference' => true, - 'magic_constant_casing' => true, - 'magic_method_casing' => true, - 'mb_str_functions' => false, // ...but potentially useful for i18n - 'method_argument_space' => [ - 'keep_multiple_spaces_after_comma' => false, - 'on_multiline' => 'ensure_fully_multiline', - ], - 'method_chaining_indentation' => true, - 'modernize_types_casting' => true, - 'multiline_comment_opening_closing' => true, - 'multiline_whitespace_before_semicolons' => [ - 'strategy' => 'no_multi_line', // vs. 'new_line_for_chained_calls' - ], - 'native_constant_invocation' => false, // Performance - 'native_function_casing' => true, - 'native_function_invocation' => false, // Performance - 'native_function_type_declaration_casing' => true, - 'new_with_braces' => true, - 'no_alias_functions' => false, // Read more on this... - 'no_alternative_syntax' => true, - 'no_binary_string' => true, - 'no_blank_lines_after_class_opening' => false, // cf. 'class_attributes_separation' - 'no_blank_lines_after_phpdoc' => false, // wrecks config - 'no_blank_lines_before_namespace' => false, // cf. 'blank_line_after_namespace' - 'no_break_comment' => true, - 'no_closing_tag' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_blank_lines' => [ - 'extra', - ], - 'no_homoglyph_names' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_mixed_echo_print' => [ - 'use' => 'echo', - ], - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_null_property_initialization' => true, - 'no_php4_constructor' => true, - 'no_short_bool_cast' => true, - 'no_short_echo_tag' => true, - 'no_singleline_whitespace_before_semicolons' => true, // TODO: Verify? - 'no_spaces_after_function_name' => true, - 'no_spaces_around_offset' => [ - 'inside', - 'outside' - ], - 'no_spaces_inside_parenthesis' => true, - 'no_superfluous_elseif' => true, - // Interesting! Detects strict typing. - // cf. https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3110 - 'no_superfluous_phpdoc_tags' => [ - 'allow_mixed' => true, - ], - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_trailing_whitespace' => true, - 'no_trailing_whitespace_in_comment' => true, - 'no_unneeded_control_parentheses' => [ - 'break', - 'clone', - 'continue', - 'echo_print', - 'return', - 'switch_case', - 'yield', - ], - 'no_unneeded_curly_braces' => true, - 'no_unneeded_final_method' => true, - 'no_unreachable_default_argument_value' => true, - 'no_unset_cast' => true, - 'no_unset_on_property' => false, - 'no_unused_imports' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'no_whitespace_before_comma_in_array' => true, - 'no_whitespace_in_blank_line' => true, - 'non_printable_character' => true, - 'normalize_index_brace' => true, - 'not_operator_with_space' => false, - 'not_operator_with_successor_space' => false, - 'object_operator_without_whitespace' => true, - // 'ordered_class_elements' => [ - // 'order' => [ - // 'use_trait', - // 'constant_public', - // 'constant_protected', - // 'constant_private', - // // 'property_public_static', - // // 'property_protected_static', - // // 'property_private_static', - // 'property_public', - // 'property_protected', - // 'property_private', - // 'construct', - // 'destruct', - // 'magic', - // 'phpunit', - // 'method_public', - // 'method_protected', - // 'method_private', - // ], - // 'sortAlgorithm' => 'none', - // ], - 'ordered_imports' => false, // https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4305 - 'ordered_interfaces' => false, // Risky! - // 'php_unit_construct' => true, - // php_unit_dedicate_assert - // php_unit_dedicate_assert_internal_type - // php_unit_expectation - // php_unit_fqcn_annotation - // php_unit_internal_class - // 'php_unit_method_casing' => [ // testSearchable conflict - // 'case' => 'snake_case', - // ], - // php_unit_mock - // php_unit_mock_short_will_return - // php_unit_namespaced - // php_unit_no_expectation_annotation - // php_unit_ordered_covers - // php_unit_set_up_tear_down_visibility - // php_unit_size_class - // php_unit_strict - // php_unit_test_annotation - // php_unit_test_case_static_method_calls - // php_unit_test_class_requires_covers - // phpdoc_add_missing_param_annotation // vs. 'no_superfluous_phpdoc_tags' - // phpdoc_align - // phpdoc_annotation_without_dot - // phpdoc_indent - // phpdoc_inline_tag - // phpdoc_no_access - // phpdoc_no_alias_tag - // phpdoc_no_empty_return - // phpdoc_no_package - // phpdoc_no_useless_inheritdoc - // phpdoc_order - // phpdoc_return_self_reference - // phpdoc_scalar - // phpdoc_separation - // phpdoc_single_line_var_spacing - // phpdoc_summary - // phpdoc_to_comment - // phpdoc_to_return_type - // phpdoc_trim - // phpdoc_trim_consecutive_blank_line_separation - // phpdoc_types - // phpdoc_types_order - // phpdoc_var_annotation_correct_order - // phpdoc_var_without_name - 'pow_to_exponentiation' => false, - 'protected_to_private' => false, // Definitely not! - 'psr0' => false, // Lowercases 'App' => 'app', etc. - 'psr4' => true, - 'random_api_migration' => false, // `rand` is alias of `mt_rand` - 'return_assignment' => false, - 'return_type_declaration' => [ - 'space_before' => 'none', - ], - 'self_accessor' => false, // Buggy with transformers - 'semicolon_after_instruction' => true, - 'set_type_to_cast' => true, - 'short_scalar_cast' => true, - 'simple_to_complex_string_variable' => false, - 'simplified_null_return' => false, - 'single_blank_line_at_eof' => true, - 'single_blank_line_before_namespace' => true, - 'single_class_element_per_statement' => [ - 'const', - 'property', - ], - 'single_import_per_statement' => true, - 'single_line_after_imports' => true, - 'single_line_comment_style' => [ - 'comment_types' => [ - // 'asterisk', // Requires using /** instead of /* - 'hash', - ], - ], - 'single_quote' => true, // Rough on CreateSwaggerDocs and Documentable - 'single_trait_insert_per_statement' => false, // Bad. Does not multiline! - 'space_after_semicolon' => false, // Buggy with lambdas - 'standardize_increment' => false, // Buggy with order - 'standardize_not_equals' => true, - 'static_lambda' => false, // But interesting... - 'strict_comparison' => true, - 'strict_param' => false, // TODO: Learn about $strict func param! - 'string_line_ending' => true, - 'switch_case_semicolon_to_colon' => true, - 'switch_case_space' => true, - 'ternary_operator_spaces' => true, - 'ternary_to_null_coalescing' => true, - 'trailing_comma_in_multiline_array' => true, - 'trim_array_spaces' => true, - 'unary_operator_spaces' => true, - 'visibility_required' => [ - 'property', - 'method', - 'const', - ], - 'void_return' => false, // Nice, but too much... - 'whitespace_after_comma_in_array' => true, - 'yoda_style' => false, - - // https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4435 - // 'single_space_after_construct' => [ - // 'constructs' => [ - // // 'break', - // 'case', - // 'catch', - // // 'continue', - // 'do', - // 'echo', - // // 'else', - // // 'elseif', - // 'for', - // 'foreach', - // 'goto', - // 'if', - // 'include', - // 'include_once', - // 'new', - // 'print', - // 'require', - // 'require_once', - // // 'return', - // 'switch', - // 'throw', - // 'try', - // 'while', - // // 'yield', - // // 'yield_from', - // ] - // ], - ]) - ->setFinder($finder) -; diff --git a/app/Models/AbstractPivot.php b/app/Models/AbstractPivot.php index 43559ef3..aec219b5 100644 --- a/app/Models/AbstractPivot.php +++ b/app/Models/AbstractPivot.php @@ -2,12 +2,13 @@ namespace App\Models; +use Aic\Hub\Foundation\Models\Concerns\Singletonable; use Illuminate\Database\Eloquent\Relations\Pivot; abstract class AbstractPivot extends Pivot { - - use Instancable, Transformable; + use Singletonable; + use Transformable; // TODO: Abstract `getDate` logic from BaseModel into Trait, so that we can `use` it here? diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index ea5c825a..37a07fe6 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -32,7 +32,7 @@ class BaseModel extends AbstractModel { - use Transformable, Instancable, Documentable, HasFactory; + use Transformable, Documentable, HasFactory; /** * The name of the field that the source API provides a last updated timestamp in. diff --git a/app/Models/Instancable.php b/app/Models/Instancable.php deleted file mode 100644 index c16fb82d..00000000 --- a/app/Models/Instancable.php +++ /dev/null @@ -1,27 +0,0 @@ -=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/master" + }, + "time": "2016-08-06T20:24:11+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.1", @@ -10778,6 +11272,132 @@ }, "time": "2021-12-12T21:44:58+00:00" }, + { + "name": "symfony/filesystem", + "version": "v5.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "0f0c4bf1840420f4aef3f32044a9dbb24682731b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f0c4bf1840420f4aef3f32044a9dbb24682731b", + "reference": "0f0c4bf1840420f4aef3f32044a9dbb24682731b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v5.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "395220730edceb6bd745236ccb5c9125c748f779" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/395220730edceb6bd745236ccb5c9125c748f779", + "reference": "395220730edceb6bd745236ccb5c9125c748f779", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/service-contracts": "^1|^2|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v5.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -10830,17 +11450,17 @@ } ], "aliases": [], - "minimum-stability": "stable", + "minimum-stability": "dev", "stability-flags": { "aic/data-hub-foundation": 20, "aic/laravel-scout-elastic": 20, "jsq/amazon-es-php": 20 }, - "prefer-stable": false, + "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^7.3|^8.0" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } From ad2b5ccdc0d53fb998086701093bfca09cff6d4d Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 2 Feb 2022 23:37:34 -0600 Subject: [PATCH 17/23] Lint code using new shared rules [API-257] --- app/Console/Commands/Delete/DeleteAssets.php | 4 +- .../Commands/Docs/CreateEndpointDocs.php | 1 - .../Commands/Docs/CreateFieldsDocs.php | 1 - .../Commands/Docs/CreateSwaggerDoc.php | 2 +- app/Console/Commands/Docs/DownloadCssJs.php | 4 +- .../Commands/Dump/AbstractDumpCommand.php | 2 +- .../Dump/DumpExportGettingStarted.php | 7 +- app/Console/Commands/Dump/DumpUpload.php | 28 +++-- app/Console/Commands/Import/ImportQueues.php | 3 - app/Console/Commands/Release.php | 1 - .../ReportArtistEmptyExploreFurther.php | 72 ++++++------ app/Console/Kernel.php | 8 +- app/Exceptions/Handler.php | 5 +- app/Helpers/Util.php | 12 +- app/Http/Controllers/AbstractController.php | 2 +- app/Http/Controllers/ArtworkController.php | 1 - app/Http/Controllers/AssetController.php | 1 + .../RestrictedResourceController.php | 1 - app/Http/Controllers/SearchController.php | 2 - app/Http/Middleware/DecodeParams.php | 1 - app/Http/Middleware/LoginIpMiddleware.php | 1 - .../PreventRequestsDuringMaintenance.php | 2 +- app/Http/Middleware/RestrictContent.php | 1 - app/Http/Middleware/ThrottleRequests.php | 1 - app/Http/Middleware/TrustProxies.php | 4 +- app/Http/Middleware/VerifyCsrfToken.php | 2 +- app/Http/Search/Request.php | 1 - app/Http/Search/Response.php | 3 +- app/Library/Slug.php | 10 +- app/Models/BaseModel.php | 32 ++--- app/Models/Collections/Artwork.php | 60 +++++----- app/Models/Collections/Asset.php | 6 +- app/Models/Collections/CategoryTerm.php | 2 +- app/Models/Documentable.php | 18 +-- app/Models/Web/Exhibition.php | 8 +- app/Providers/ResourceServiceProvider.php | 2 +- app/Scopes/PublishedScope.php | 3 - app/Scopes/UnlistedScope.php | 3 - .../Inbound/Collections/Asset.php | 2 +- .../Inbound/Collections/Category.php | 2 +- app/Transformers/Inbound/Collections/Term.php | 2 +- .../Inbound/CollectionsTransformer.php | 2 +- app/Transformers/Inbound/Web/Experience.php | 1 - .../Inbound/Web/InteractiveFeature.php | 1 - .../Outbound/Collections/ArtworkManifest.php | 10 +- app/Transformers/Outbound/Shop/Product.php | 2 +- config/filesystems.php | 1 - config/logging.php | 1 - config/resources/outbound.php | 1 - config/sanctum.php | 2 +- config/sentry.php | 4 +- .../Membership/MembershipFactory.php | 41 +++---- ...31_remove_copyright_notice_from_assets.php | 1 - .../2021_05_23_120928_remove_qless_queues.php | 2 +- ...125600_rename_selections_to_highlights.php | 1 - tests/Basic/ArtworkTest.php | 1 - tests/Contract/ArtworkTest.php | 110 +++++++++--------- tests/Contract/ContractTestCase.php | 5 +- tests/Contract/ExhibitionTest.php | 2 - tests/Helpers/Factory.php | 2 - 60 files changed, 237 insertions(+), 276 deletions(-) diff --git a/app/Console/Commands/Delete/DeleteAssets.php b/app/Console/Commands/Delete/DeleteAssets.php index f2a03b06..73225506 100644 --- a/app/Console/Commands/Delete/DeleteAssets.php +++ b/app/Console/Commands/Delete/DeleteAssets.php @@ -73,9 +73,9 @@ private function shallow() $this->warn('Deleting ' . $modelClass . ' ' . $datum->asset_id); $model->delete(); break; - } else { - $this->info('Skipped ' . $modelClass . ' ' . $datum->asset_id . ' because it is newer'); } + + $this->info('Skipped ' . $modelClass . ' ' . $datum->asset_id . ' because it is newer'); } } } diff --git a/app/Console/Commands/Docs/CreateEndpointDocs.php b/app/Console/Commands/Docs/CreateEndpointDocs.php index e80d5167..76495f06 100644 --- a/app/Console/Commands/Docs/CreateEndpointDocs.php +++ b/app/Console/Commands/Docs/CreateEndpointDocs.php @@ -3,7 +3,6 @@ namespace App\Console\Commands\Docs; use Illuminate\Support\Facades\Storage; -use Carbon\Carbon; class CreateEndpointDocs extends AbstractDocCommand { diff --git a/app/Console/Commands/Docs/CreateFieldsDocs.php b/app/Console/Commands/Docs/CreateFieldsDocs.php index 23a17335..7d580361 100644 --- a/app/Console/Commands/Docs/CreateFieldsDocs.php +++ b/app/Console/Commands/Docs/CreateFieldsDocs.php @@ -3,7 +3,6 @@ namespace App\Console\Commands\Docs; use Illuminate\Support\Facades\Storage; -use Carbon\Carbon; class CreateFieldsDocs extends AbstractDocCommand { diff --git a/app/Console/Commands/Docs/CreateSwaggerDoc.php b/app/Console/Commands/Docs/CreateSwaggerDoc.php index 0fac120d..46a400d0 100644 --- a/app/Console/Commands/Docs/CreateSwaggerDoc.php +++ b/app/Console/Commands/Docs/CreateSwaggerDoc.php @@ -168,7 +168,7 @@ public function handle() $doc .= " },\n"; $doc .= " \"externalDocs\": {\n"; $doc .= " \"description\": \"See more documentation on our API here:\",\n"; - $doc .= " \"url\": \"" . config('app.url') . "\"\n"; + $doc .= ' "url": "' . config('app.url') . "\"\n"; $doc .= " }\n"; $doc .= "}\n"; diff --git a/app/Console/Commands/Docs/DownloadCssJs.php b/app/Console/Commands/Docs/DownloadCssJs.php index 328928f8..e6445f1c 100644 --- a/app/Console/Commands/Docs/DownloadCssJs.php +++ b/app/Console/Commands/Docs/DownloadCssJs.php @@ -3,7 +3,6 @@ namespace App\Console\Commands\Docs; use Illuminate\Support\Facades\Storage; -use Carbon\Carbon; class DownloadCssJs extends AbstractDocCommand { @@ -39,12 +38,13 @@ public function handle() ); foreach ($files as $vanityName => $fileName) { - $contents = file_get_contents('https://www.artic.edu/dist/' .$fileName); + $contents = file_get_contents('https://www.artic.edu/dist/' . $fileName); Storage::disk('local')->put($vanityName, $contents); $dest = base_path('docs/.vuepress/public/assets/' . $vanityName); $path = pathinfo($dest); + if (!file_exists($path['dirname'])) { mkdir($path['dirname'], 0777, true); } diff --git a/app/Console/Commands/Dump/AbstractDumpCommand.php b/app/Console/Commands/Dump/AbstractDumpCommand.php index a55ab87f..b5da3f7c 100644 --- a/app/Console/Commands/Dump/AbstractDumpCommand.php +++ b/app/Console/Commands/Dump/AbstractDumpCommand.php @@ -31,7 +31,7 @@ protected function getResources() $transformerClass = app('Resources')->getTransformerForModel($model); return [ 'model' => $model, - 'transformer' => new $transformerClass, + 'transformer' => new $transformerClass(), 'endpoint' => app('Resources')->getEndpointForModel($model), ]; }); diff --git a/app/Console/Commands/Dump/DumpExportGettingStarted.php b/app/Console/Commands/Dump/DumpExportGettingStarted.php index c6bc70ff..a008e63e 100644 --- a/app/Console/Commands/Dump/DumpExportGettingStarted.php +++ b/app/Console/Commands/Dump/DumpExportGettingStarted.php @@ -3,10 +3,6 @@ namespace App\Console\Commands\Dump; use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Facades\Schema; -use Illuminate\Support\Facades\DB; -use Exception; -use Throwable; use League\Csv\Writer; @@ -26,6 +22,7 @@ public function handle() // Remove the old getting started JSON in this dump $filepath = $this->getDumpPath('local/getting-started'); + if (!file_exists($filepath)) { mkdir($filepath, 0777, true); } @@ -33,7 +30,7 @@ public function handle() // Create transformer used for generating JSON output $transformer = app('Resources')->getTransformerForModel($model); - $transformer = new $transformer; + $transformer = new $transformer(); $csv = $this->getNewWriter($filepath . '/someArtworks.csv', [ 'id', diff --git a/app/Console/Commands/Dump/DumpUpload.php b/app/Console/Commands/Dump/DumpUpload.php index 0e00c9b2..8f3c03ad 100644 --- a/app/Console/Commands/Dump/DumpUpload.php +++ b/app/Console/Commands/Dump/DumpUpload.php @@ -31,6 +31,7 @@ public function handle() if ($this->isDirEmpty($jsonsSrcPath)) { throw new Exception('No JSON files found in ' . $jsonsSrcPath); } + if ($this->isDirEmpty($gettingStartedSrcPath)) { throw new Exception('No getting started files found in ' . $gettingStartedSrcPath); } @@ -57,29 +58,30 @@ public function handle() // Copy dumps of whitelisted tables and endpoints into the repo $this->shell->passthru('rsync -r %s/ %s', $srcPath . '/getting-started', $repoPath . '/getting-started'); - $this->shell->passthru(" + $this->shell->passthru(' for file in %s/*; do - if [ -f \$file ]; then - cp %s/$(basename \$file) %s/ + if [ -f $file ]; then + cp %s/$(basename $file) %s/ fi done - ", $srcPath, $srcPath, $repoPath); + ', $srcPath, $srcPath, $repoPath); $this->shell->passthru('mkdir %s', $repoPath . '/json'); - $endpointResult = $this->shell->exec(" + $endpointResult = $this->shell->exec(' for DIR_SRC in %s/json/*; do - if [ -d \"\$DIR_SRC\" ]; then - DIR_DEST=%s/json/$(basename \"\$DIR_SRC\") - mkdir \"\$DIR_DEST\" - echo \"\$(basename \"\$DIR_SRC\")\" + if [ -d "$DIR_SRC" ]; then + DIR_DEST=%s/json/$(basename "$DIR_SRC") + mkdir "$DIR_DEST" + echo "$(basename "$DIR_SRC")" fi done - ", $srcPath, $repoPath); + ', $srcPath, $repoPath); // First, copy only 10 items from each endpoint foreach ($endpointResult['output'] as $endpoint) { // https://stackoverflow.com/questions/11296809/how-to-avoid-ls-write-error-broken-pipe-with-php-exec $fileResult = $this->shell->exec('ls -p1 %s/json/%s | grep -v / | sort -n -k1 2>/dev/null | head -10', $srcPath, $endpoint); + foreach ($fileResult['output'] as $file) { $this->shell->exec( 'cp %s/json/%s/%s %s/json/%s', @@ -136,9 +138,11 @@ public function handle() protected function isDirEmpty($dir) { $handle = opendir($dir); + while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - $file = $dir.$entry; + if ($entry != '.' && $entry != '..') { + $file = $dir . $entry; + if (is_dir($file)) { if (!$this->isDirEmpty($file)) { closedir($handle); diff --git a/app/Console/Commands/Import/ImportQueues.php b/app/Console/Commands/Import/ImportQueues.php index ce50b0ce..ffc75c0a 100644 --- a/app/Console/Commands/Import/ImportQueues.php +++ b/app/Console/Commands/Import/ImportQueues.php @@ -2,10 +2,7 @@ namespace App\Console\Commands\Import; -use Illuminate\Support\Facades\Storage; - use App\Models\Queues\WaitTime; -use App\Transformers\Inbound\BaseTransformer; class ImportQueues extends AbstractImportCommand { diff --git a/app/Console/Commands/Release.php b/app/Console/Commands/Release.php index 2f60086a..faf02e6f 100644 --- a/app/Console/Commands/Release.php +++ b/app/Console/Commands/Release.php @@ -3,7 +3,6 @@ namespace App\Console\Commands; use Illuminate\Support\Facades\Storage; -use Carbon\Carbon; class Release extends BaseCommand { diff --git a/app/Console/Commands/Report/ReportArtistEmptyExploreFurther.php b/app/Console/Commands/Report/ReportArtistEmptyExploreFurther.php index d4329482..07c2119e 100644 --- a/app/Console/Commands/Report/ReportArtistEmptyExploreFurther.php +++ b/app/Console/Commands/Report/ReportArtistEmptyExploreFurther.php @@ -10,7 +10,7 @@ use Aic\Hub\Foundation\AbstractCommand as BaseCommand; -use \Elasticsearch; +use Elasticsearch; class ReportArtistEmptyExploreFurther extends BaseCommand { @@ -47,27 +47,27 @@ public function handle() 'resources' => 'artworks', 'limit' => 1, 'query' => [ - "bool" => [ - "must" => [ + 'bool' => [ + 'must' => [ [ - "term"=> [ - "artist_ids" => $artist->citi_id + 'term' => [ + 'artist_ids' => $artist->citi_id ] ] ] ], ], - "aggregations" => [ - "place_of_origin" => [ - "terms" => [ - "field" => "place_of_origin.keyword", - "size" => 1, + 'aggregations' => [ + 'place_of_origin' => [ + 'terms' => [ + 'field' => 'place_of_origin.keyword', + 'size' => 1, ] ], - "styles" => [ - "terms" => [ - "field" => "style_titles.keyword", - "size" => 1, + 'styles' => [ + 'terms' => [ + 'field' => 'style_titles.keyword', + 'size' => 1, ] ] ] @@ -83,35 +83,37 @@ public function handle() $this->csv->insertOne([$artist->citi_id, $artist->title, 'http://www.artic.edu/artists/' . $artist->citi_id, 'No place_of_origin or style on any artwork records related to this artist']); } else { $shoulds = []; + if ($place_of_origin) { $shoulds[] = [ - "match"=> [ - "place_of_origin" => $place_of_origin + 'match' => [ + 'place_of_origin' => $place_of_origin ] ]; } + if ($style) { $shoulds[] = [ - "match"=> [ - "style_titles" => $style + 'match' => [ + 'style_titles' => $style ] ]; } $shoulds[] = [ - "bool" => [ - "must" => [ + 'bool' => [ + 'must' => [ [ - "range" => [ - "date_start" => [ - "gte" => $artist->birth_date + 'range' => [ + 'date_start' => [ + 'gte' => $artist->birth_date ] ] ], [ - "range" => [ - "date_end" => [ - "lte" => $artist->death_date ?? date('Y') + 'range' => [ + 'date_end' => [ + 'lte' => $artist->death_date ?? date('Y') ] ] ] @@ -129,17 +131,17 @@ public function handle() 'page' => 1, 'fields' => ['id', 'title'], 'query' => [ - "bool" => [ - "should" => $shoulds, - "minimum_should_match" => 2, - "filter" => [ - "exists" => [ - "field" => "image_id" + 'bool' => [ + 'should' => $shoulds, + 'minimum_should_match' => 2, + 'filter' => [ + 'exists' => [ + 'field' => 'image_id' ] ], - "must_not" => [ - "term" => [ - "artist_id" => 37259 + 'must_not' => [ + 'term' => [ + 'artist_id' => 37259 ] ] ] diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a3ec9f09..7c35ab0d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,8 +2,6 @@ namespace App\Console; -use Illuminate\Support\Facades\App; - use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -21,7 +19,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // + ]; /** @@ -80,8 +78,8 @@ protected function schedule(Schedule $schedule) // API-231, API-232: Temporary remediation! Artworks can't touch artists. $schedule->command('scout:import', [ - \App\Models\Collections\Agent::class, - ]) + \App\Models\Collections\Agent::class, + ]) ->hourly() ->withoutOverlapping(self::FOR_ONE_YEAR) ->sendOutputTo(storage_path('logs/scout-import-agents-last-run.log')); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 07749007..2358ad24 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -13,7 +13,7 @@ class Handler extends ExceptionHandler * @var string[] */ protected $dontReport = [ - // + ]; /** @@ -22,13 +22,12 @@ class Handler extends ExceptionHandler * @var string[] */ protected $dontFlash = [ - // + ]; /** * Report or log an exception. * - * @param \Throwable $exception * @return void * * @throws \Throwable diff --git a/app/Helpers/Util.php b/app/Helpers/Util.php index dc093094..c4cd1075 100644 --- a/app/Helpers/Util.php +++ b/app/Helpers/Util.php @@ -1,9 +1,5 @@ input())->except('page')->all()); + if ($collection->previousPageUrl()) { $paginator['prev_url'] = $collection->previousPageUrl() . ($params ? '&' . $params : ''); } diff --git a/app/Http/Controllers/ArtworkController.php b/app/Http/Controllers/ArtworkController.php index c76a9052..646dcd87 100644 --- a/app/Http/Controllers/ArtworkController.php +++ b/app/Http/Controllers/ArtworkController.php @@ -4,7 +4,6 @@ use Illuminate\Http\Request; -use League\Fractal\Manager; use League\Fractal\Resource\Item; use League\Fractal\Serializer\ArraySerializer; diff --git a/app/Http/Controllers/AssetController.php b/app/Http/Controllers/AssetController.php index 9b7fda8d..25b006a7 100644 --- a/app/Http/Controllers/AssetController.php +++ b/app/Http/Controllers/AssetController.php @@ -16,6 +16,7 @@ public function netx(Request $request, $id) $isNetx = true; } else { $asset = Asset::where('lake_guid', $id)->first(); + if ($asset) { $isNetx = false; } else { diff --git a/app/Http/Controllers/RestrictedResourceController.php b/app/Http/Controllers/RestrictedResourceController.php index d4944d6c..1254d068 100644 --- a/app/Http/Controllers/RestrictedResourceController.php +++ b/app/Http/Controllers/RestrictedResourceController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use Aic\Hub\Foundation\Exceptions\UnauthorizedException; diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0b8ad606..d3a73e6c 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -7,8 +7,6 @@ use App\Http\Search\Request as SearchRequest; use App\Http\Search\Response as SearchResponse; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Request as RequestFacade; use Illuminate\Http\Request; use Elasticsearch; diff --git a/app/Http/Middleware/DecodeParams.php b/app/Http/Middleware/DecodeParams.php index 8c494944..29487a0b 100644 --- a/app/Http/Middleware/DecodeParams.php +++ b/app/Http/Middleware/DecodeParams.php @@ -12,7 +12,6 @@ class DecodeParams * quirks. You can pass any API params as a JSON string via the `params` param. * * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/LoginIpMiddleware.php b/app/Http/Middleware/LoginIpMiddleware.php index 97c74e2e..2dc798ca 100644 --- a/app/Http/Middleware/LoginIpMiddleware.php +++ b/app/Http/Middleware/LoginIpMiddleware.php @@ -10,7 +10,6 @@ class LoginIpMiddleware * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/Http/Middleware/PreventRequestsDuringMaintenance.php index e4956d0b..59d4cb06 100644 --- a/app/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/app/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -12,6 +12,6 @@ class PreventRequestsDuringMaintenance extends Middleware * @var array */ protected $except = [ - // + ]; } diff --git a/app/Http/Middleware/RestrictContent.php b/app/Http/Middleware/RestrictContent.php index 4a81ae07..45a1f70a 100644 --- a/app/Http/Middleware/RestrictContent.php +++ b/app/Http/Middleware/RestrictContent.php @@ -7,7 +7,6 @@ use Closure; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use App\Models\BaseModel; diff --git a/app/Http/Middleware/ThrottleRequests.php b/app/Http/Middleware/ThrottleRequests.php index c892817a..0976e5d5 100644 --- a/app/Http/Middleware/ThrottleRequests.php +++ b/app/Http/Middleware/ThrottleRequests.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use Closure; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use Illuminate\Routing\Middleware\ThrottleRequests as BaseMiddleware; diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 9b143cfc..7170092b 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -47,8 +47,8 @@ public function handle(Request $request, Closure $next) $this->proxies = array_merge( $this->proxies, - $ips->{"CLOUDFRONT_GLOBAL_IP_LIST"}, - $ips->{"CLOUDFRONT_REGIONAL_EDGE_IP_LIST"} + $ips->{'CLOUDFRONT_GLOBAL_IP_LIST'}, + $ips->{'CLOUDFRONT_REGIONAL_EDGE_IP_LIST'} ); array_push($this->proxies, $request->server->get('REMOTE_ADDR')); diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 0c13b854..f1e650cd 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware * @var array */ protected $except = [ - // + ]; } diff --git a/app/Http/Search/Request.php b/app/Http/Search/Request.php index 09fbbcbd..f5e3552a 100644 --- a/app/Http/Search/Request.php +++ b/app/Http/Search/Request.php @@ -9,7 +9,6 @@ use App\Http\Middleware\RestrictContent; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Request as RequestFacade; diff --git a/app/Http/Search/Response.php b/app/Http/Search/Response.php index b0051587..16935934 100644 --- a/app/Http/Search/Response.php +++ b/app/Http/Search/Response.php @@ -3,7 +3,6 @@ namespace App\Http\Search; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Request as RequestFacade; @@ -221,7 +220,7 @@ private function info() $transformers = array_map(function ($resource) { $transformer = app('Resources')->getTransformerForEndpoint($resource); - return new $transformer; + return new $transformer(); }, $resources); // Sort transformers by license priority, ascending: diff --git a/app/Library/Slug.php b/app/Library/Slug.php index baede493..f0d9813c 100644 --- a/app/Library/Slug.php +++ b/app/Library/Slug.php @@ -9,18 +9,18 @@ public static function getUtf8Slug($str, $options = []) // Make sure string is in UTF-8 and strip invalid UTF-8 characters $str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings()); - $defaults = array( + $defaults = [ 'delimiter' => '-', 'limit' => null, 'lowercase' => true, - 'replacements' => array(), + 'replacements' => [], 'transliterate' => true, - ); + ]; // Merge options $options = array_merge($defaults, $options); - $char_map = array( + $char_map = [ // Latin 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', @@ -85,7 +85,7 @@ public static function getUtf8Slug($str, $options = []) 'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z', 'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'š' => 's', 'ū' => 'u', 'ž' => 'z', - ); + ]; // Make custom replacements $str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str); diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 37a07fe6..b1935fca 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -134,22 +134,22 @@ protected function newBelongsToMany( public static function addRestrictContentScopes($isDump = false) { - Article::addGlobalScope(new PublishedScope); - DigitalCatalog::addGlobalScope(new PublishedScope); - DigitalPublicationSection::addGlobalScope(new PublishedScope); - EducatorResource::addGlobalScope(new PublishedScope); - GenericPage::addGlobalScope(new PublishedScope); - PressRelease::addGlobalScope(new PublishedScope); - PrintedCatalog::addGlobalScope(new PublishedScope); - Highlight::addGlobalScope(new PublishedScope); - Sponsor::addGlobalScope(new PublishedScope); - StaticPage::addGlobalScope(new PublishedScope); - WebExhibition::addGlobalScope(new PublishedScope); + Article::addGlobalScope(new PublishedScope()); + DigitalCatalog::addGlobalScope(new PublishedScope()); + DigitalPublicationSection::addGlobalScope(new PublishedScope()); + EducatorResource::addGlobalScope(new PublishedScope()); + GenericPage::addGlobalScope(new PublishedScope()); + PressRelease::addGlobalScope(new PublishedScope()); + PrintedCatalog::addGlobalScope(new PublishedScope()); + Highlight::addGlobalScope(new PublishedScope()); + Sponsor::addGlobalScope(new PublishedScope()); + StaticPage::addGlobalScope(new PublishedScope()); + WebExhibition::addGlobalScope(new PublishedScope()); if ($isDump) { - Event::addGlobalScope(new PublishedScope); - EventOccurrence::addGlobalScope(new PublishedScope); - Product::addGlobalScope(new PublishedScope); + Event::addGlobalScope(new PublishedScope()); + EventOccurrence::addGlobalScope(new PublishedScope()); + Product::addGlobalScope(new PublishedScope()); } Exhibition::addGlobalScope('is-web-exhibition-published', function (Builder $builder) { @@ -166,8 +166,8 @@ public static function addRestrictContentScopes($isDump = false) // WEB-1419: Using subquery here instead of join to avoid field overrides $builder->orWhereIn('citi_id', function ($query) { $query->select('datahub_id') - ->from('web_exhibitions') - ->where('is_published', '=', true); + ->from('web_exhibitions') + ->where('is_published', '=', true); }); }); } diff --git a/app/Models/Collections/Artwork.php b/app/Models/Collections/Artwork.php index d2518aff..f675c894 100644 --- a/app/Models/Collections/Artwork.php +++ b/app/Models/Collections/Artwork.php @@ -399,36 +399,36 @@ public static function boostedIds() { return array_merge( [ - 185651, 183077, 151358, 99539, 189595, 187528, 102611, 111401, 91620, 18757, 51185, 55249, 14968, 65290, 75644, - 106538, 59787, 103347, 104094, 100829, 76571, 154237, 154238, 149776, 120154, 44018, 56905, 102295, 105105, 184672, - 111442, 25865, 72801, 97916, 190558, 36161, 15401, 69780, 64724, 185905, 65916, 40619, 151371, 63178, 104031, - 46327, 6565, 83905, 111628, 117266, 56682, 156538, 196323, 71829, 105203, 131541, 192890, 104043, 189289, 189290, - 144272, 190224, 102963, 191197, 188540, 188845, 64339, 159136, 70207, 185963, 70003, 35376, 42566, 88724, 43060, - 76279, 183277, 73216, 185180, 111380, 56731, 9512, 11272, 127644, 185222, 88977, 89856, 24645, 153244, 24548, - 21023, 13853, 34286, 49195, 86340, 142526, 58540, 69109, 99766, 16964, 73417, 79379, 76244, 83642, 157156, - 100472, 4884, 147003, 86385, 146991, 186049, 71396, 35198, 97402, 68823, 102234, 184362, 146988, 93345, 191371, - 47149, 90583, 107069, 110634, 100250, 160222, 147513, 146989, 76054, 90443, 187165, 157160, 159824, 192689, 137125, - 148306, 140645, 186392, 182728, 154232, 184193, 184186, 181091, 160226, 181774, 189207, 184095, 181145, 34116, 156442, - 189715, 57819, 126981, 147508, 6596, 50330, 68769, 186047, 103943, 111400, 107300, 148412, 43714, 46230, 50909, - 25332, 52560, 16231, 15468, 16169, 184324, 16327, 184371, 23972, 25853, 199854, 112092, 44741, 87479, 84709, - 27310, 73413, 95998, 11434, 5848, 60755, 16488, 4788, 93900, 57051, 27307, 16362, 102591, 111317, 110663, - 144969, 4758, 4796, 44892, 14598, 81512, 11723, 20684, 81558, 14655, 11320, 110507, 14572, 27992, 16487, - 80607, 19339, 28560, 64818, 61128, 60812, 111436, 28067, 16568, 87045, 109330, 66039, 79307, 111060, 9503, - 8624, 8991, 80062, 185766, 30839, 27987, 91194, 144361, 2816, 109819, 153701, 109275, 27984, 7124, 111654, - 118746, 37761, 185760, 72728, 5357, 61608, 185184, 84241, 151424, 59426, 34181, 111642, 20509, 38930, 145681, - 63554, 157056, 66683, 66434, 119454, 55384, 70739, 50157, 100079, 50148, 13720, 100089, 87163, 63234, 188844, - 191454, 117271, 160201, 187155, 110881, 23506, 105073, 60031, 90536, 20432, 103887, 76295, 102131, 52736, 50276, - 76779, 61603, 111164, 160144, 18709, 16776, 76395, 72726, 70202, 23684, 135430, 83889, 111810, 131385, 122054, - 90300, 99602, 149681, 85533, 189600, 36132, 70443, 80479, 189775, 52679, 86421, 49691, 150739, 180298, 185619, - 155969, 64884, 109686, 16298, 4575, 4081, 105466, 59847, 62042, 80084, 146953, 869, 43145, 23333, 111610, - 111559, 4773, 4428, 16499, 14574, 20579, 16571, 14591, 16146, 62371, 154235, 109926, 49702, 150054, 55706, - 90048, 30709, 146701, 81564, 28849, 111377, 97910, 64729, 8958, 31285, 87643, 119521, 76240, 109780, 79600, - 23700, 65868, 93811, 61428, 64276, 111617, 117188, 49714, 125660, 2189, 146905, 89403, 127859, 88793, 79507, - 92975, 234781, 76816, 76869, 210511, 193664, 210482, 16551, 11393, 7021, 207293, 156474, 234972, 49686, 105800, - 118661, 217201, 191556, 198809, 34299, 15563, 220272, 229354, 229351, 229406, 223309, 129884, 234004, 227420, 24836, - 234433, 218612, 199002, 229510, 189932, 230189, 225016, 221885, 229866, 109439, 869, 4081, 4773, 16146, 23333, 23700, - 30709, 31285, 43145, 49702, 62042, 62371, 76240, 79600, 81564, 105466, 109926, 111377, 111559, 119521, 146701, 146953, - 150054, 238749, 100858, 229393, 151363, 53001, 189807, 9010, 220179, 37368, + 185651, 183077, 151358, 99539, 189595, 187528, 102611, 111401, 91620, 18757, 51185, 55249, 14968, 65290, 75644, + 106538, 59787, 103347, 104094, 100829, 76571, 154237, 154238, 149776, 120154, 44018, 56905, 102295, 105105, 184672, + 111442, 25865, 72801, 97916, 190558, 36161, 15401, 69780, 64724, 185905, 65916, 40619, 151371, 63178, 104031, + 46327, 6565, 83905, 111628, 117266, 56682, 156538, 196323, 71829, 105203, 131541, 192890, 104043, 189289, 189290, + 144272, 190224, 102963, 191197, 188540, 188845, 64339, 159136, 70207, 185963, 70003, 35376, 42566, 88724, 43060, + 76279, 183277, 73216, 185180, 111380, 56731, 9512, 11272, 127644, 185222, 88977, 89856, 24645, 153244, 24548, + 21023, 13853, 34286, 49195, 86340, 142526, 58540, 69109, 99766, 16964, 73417, 79379, 76244, 83642, 157156, + 100472, 4884, 147003, 86385, 146991, 186049, 71396, 35198, 97402, 68823, 102234, 184362, 146988, 93345, 191371, + 47149, 90583, 107069, 110634, 100250, 160222, 147513, 146989, 76054, 90443, 187165, 157160, 159824, 192689, 137125, + 148306, 140645, 186392, 182728, 154232, 184193, 184186, 181091, 160226, 181774, 189207, 184095, 181145, 34116, 156442, + 189715, 57819, 126981, 147508, 6596, 50330, 68769, 186047, 103943, 111400, 107300, 148412, 43714, 46230, 50909, + 25332, 52560, 16231, 15468, 16169, 184324, 16327, 184371, 23972, 25853, 199854, 112092, 44741, 87479, 84709, + 27310, 73413, 95998, 11434, 5848, 60755, 16488, 4788, 93900, 57051, 27307, 16362, 102591, 111317, 110663, + 144969, 4758, 4796, 44892, 14598, 81512, 11723, 20684, 81558, 14655, 11320, 110507, 14572, 27992, 16487, + 80607, 19339, 28560, 64818, 61128, 60812, 111436, 28067, 16568, 87045, 109330, 66039, 79307, 111060, 9503, + 8624, 8991, 80062, 185766, 30839, 27987, 91194, 144361, 2816, 109819, 153701, 109275, 27984, 7124, 111654, + 118746, 37761, 185760, 72728, 5357, 61608, 185184, 84241, 151424, 59426, 34181, 111642, 20509, 38930, 145681, + 63554, 157056, 66683, 66434, 119454, 55384, 70739, 50157, 100079, 50148, 13720, 100089, 87163, 63234, 188844, + 191454, 117271, 160201, 187155, 110881, 23506, 105073, 60031, 90536, 20432, 103887, 76295, 102131, 52736, 50276, + 76779, 61603, 111164, 160144, 18709, 16776, 76395, 72726, 70202, 23684, 135430, 83889, 111810, 131385, 122054, + 90300, 99602, 149681, 85533, 189600, 36132, 70443, 80479, 189775, 52679, 86421, 49691, 150739, 180298, 185619, + 155969, 64884, 109686, 16298, 4575, 4081, 105466, 59847, 62042, 80084, 146953, 869, 43145, 23333, 111610, + 111559, 4773, 4428, 16499, 14574, 20579, 16571, 14591, 16146, 62371, 154235, 109926, 49702, 150054, 55706, + 90048, 30709, 146701, 81564, 28849, 111377, 97910, 64729, 8958, 31285, 87643, 119521, 76240, 109780, 79600, + 23700, 65868, 93811, 61428, 64276, 111617, 117188, 49714, 125660, 2189, 146905, 89403, 127859, 88793, 79507, + 92975, 234781, 76816, 76869, 210511, 193664, 210482, 16551, 11393, 7021, 207293, 156474, 234972, 49686, 105800, + 118661, 217201, 191556, 198809, 34299, 15563, 220272, 229354, 229351, 229406, 223309, 129884, 234004, 227420, 24836, + 234433, 218612, 199002, 229510, 189932, 230189, 225016, 221885, 229866, 109439, 869, 4081, 4773, 16146, 23333, 23700, + 30709, 31285, 43145, 49702, 62042, 62371, 76240, 79600, 81564, 105466, 109926, 111377, 111559, 119521, 146701, 146953, + 150054, 238749, 100858, 229393, 151363, 53001, 189807, 9010, 220179, 37368, ], self::getFeaturedIds() ); diff --git a/app/Models/Collections/Asset.php b/app/Models/Collections/Asset.php index 30403a91..88c9eeff 100644 --- a/app/Models/Collections/Asset.php +++ b/app/Models/Collections/Asset.php @@ -21,7 +21,7 @@ class Asset extends CollectionsModel // WEB-1870: We can't set this conditionally; default to NetX over LAKE // public static $sourceLastUpdateDateField = 'indexed_at'; - protected static $assetType = null; + protected static $assetType; protected $primaryKey = 'lake_guid'; @@ -66,8 +66,8 @@ public static function getHashedId($id) } $hash = (string) hash('md5', env('ASSET_PREFIX', '') . $id); - return substr($hash, 0, 8) . '-' - . substr($hash, 8, 4) . '-' + return substr($hash, 0, 8) . '-' + . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20); diff --git a/app/Models/Collections/CategoryTerm.php b/app/Models/Collections/CategoryTerm.php index 9c04f379..adb80be8 100644 --- a/app/Models/Collections/CategoryTerm.php +++ b/app/Models/Collections/CategoryTerm.php @@ -22,7 +22,7 @@ class CategoryTerm extends CollectionsModel public const DEPARTMENT = 'CT-1'; public const THEME = 'CT-3'; - protected static $isCategory = null; + protected static $isCategory; protected $primaryKey = 'lake_uid'; protected $keyType = 'string'; diff --git a/app/Models/Documentable.php b/app/Models/Documentable.php index 1381edde..5adc497a 100644 --- a/app/Models/Documentable.php +++ b/app/Models/Documentable.php @@ -79,7 +79,7 @@ public function docTitle() public function docLicense() { $transformer = app('Resources')->getTransformerForModel(get_called_class()); - $transformer = new $transformer; + $transformer = new $transformer(); return '_' . $transformer->getLicenseText() . '_'; } @@ -208,10 +208,10 @@ public function docSingle() } /** - * For this resource, add this to the full documentation. - * - * @return string - */ + * For this resource, add this to the full documentation. + * + * @return string + */ public function docExtra() { return ''; @@ -373,6 +373,7 @@ public function docExampleOutput($options = [], $captureSampleId = false) $response->data = $this->_addEllipsis($response->data); } } + if (property_exists($response, 'metadata')) { $response->metadata = $this->_addEllipsis($response->metadata); } @@ -402,7 +403,7 @@ public function docExampleSearchOutput($getParams = '') { $appUrl = $this->docAppUrl . $this->_endpointPath() . '/search' . ($getParams ? '?' . $getParams : ''); - $doc = "::: details Example request: " . $appUrl . "\n"; + $doc = '::: details Example request: ' . $appUrl . "\n"; $response = json_decode(file_get_contents($appUrl)); sleep(1); // Throttle requests to the API @@ -462,7 +463,7 @@ public function exampleSearchQuery() */ public function exampleId() { - self::addGlobalScope(new PublishedScope); + self::addGlobalScope(new PublishedScope()); $exampleRecord = self::first(); return $exampleRecord ? $exampleRecord->getKey() : null; @@ -735,7 +736,7 @@ protected function _endpointPath($options = []) } } - return rtrim($path, "/"); + return rtrim($path, '/'); } private function _addEllipsis($obj) @@ -755,6 +756,7 @@ private function _addEllipsis($obj) $obj->{'...'} = null; } + if (is_array($obj)) { $keys = array_keys($obj); $addEllipsis = false; diff --git a/app/Models/Web/Exhibition.php b/app/Models/Web/Exhibition.php index 7c87af87..18ed79ff 100644 --- a/app/Models/Web/Exhibition.php +++ b/app/Models/Web/Exhibition.php @@ -30,10 +30,10 @@ public function exhibition() } /** - * Create a new factory instance for the model. - * - * @return \Illuminate\Database\Eloquent\Factories\Factory - */ + * Create a new factory instance for the model. + * + * @return \Illuminate\Database\Eloquent\Factories\Factory + */ protected static function newFactory() { return \Database\Factories\Web\ExhibitionFactory::new(); diff --git a/app/Providers/ResourceServiceProvider.php b/app/Providers/ResourceServiceProvider.php index 80b55f35..2e057bb1 100644 --- a/app/Providers/ResourceServiceProvider.php +++ b/app/Providers/ResourceServiceProvider.php @@ -153,7 +153,7 @@ public function getRetrictedFieldNamesForEndpoint($endpoint) { $transformerClass = $this->getTransformerForEndpoint($endpoint); - $mappedFields = (new $transformerClass)->getMappedFields(); + $mappedFields = (new $transformerClass())->getMappedFields(); $restrictedFields = array_filter($mappedFields, function ($mappedField) { return ($mappedField['is_restricted'] ?? false) === true; diff --git a/app/Scopes/PublishedScope.php b/app/Scopes/PublishedScope.php index a055e503..9b44624e 100644 --- a/app/Scopes/PublishedScope.php +++ b/app/Scopes/PublishedScope.php @@ -14,8 +14,6 @@ class PublishedScope implements Scope /** * Apply the scope to a given Eloquent query builder. * - * @param \Illuminate\Database\Eloquent\Builder $builder - * @param \Illuminate\Database\Eloquent\Model $model * @return void */ public function apply(Builder $builder, Model $model) @@ -50,7 +48,6 @@ public function apply(Builder $builder, Model $model) }); } - public static function forSearch() { return [ diff --git a/app/Scopes/UnlistedScope.php b/app/Scopes/UnlistedScope.php index 4ee92623..2dce1e96 100644 --- a/app/Scopes/UnlistedScope.php +++ b/app/Scopes/UnlistedScope.php @@ -14,8 +14,6 @@ class UnlistedScope implements Scope /** * Apply the scope to a given Eloquent query builder. * - * @param \Illuminate\Database\Eloquent\Builder $builder - * @param \Illuminate\Database\Eloquent\Model $model * @return void */ public function apply(Builder $builder, Model $model) @@ -47,7 +45,6 @@ public function apply(Builder $builder, Model $model) }); } - public static function forSearch() { return [ diff --git a/app/Transformers/Inbound/Collections/Asset.php b/app/Transformers/Inbound/Collections/Asset.php index cdb4eec8..3e249fd3 100644 --- a/app/Transformers/Inbound/Collections/Asset.php +++ b/app/Transformers/Inbound/Collections/Asset.php @@ -10,7 +10,7 @@ class Asset extends CollectionsTransformer protected function getIds(Datum $datum) { - return [ + return [ 'lake_guid' => strval($datum->id), 'netx_uuid' => \App\Models\Collections\Asset::getHashedId($datum->id), ]; diff --git a/app/Transformers/Inbound/Collections/Category.php b/app/Transformers/Inbound/Collections/Category.php index 2438ae13..70090e55 100644 --- a/app/Transformers/Inbound/Collections/Category.php +++ b/app/Transformers/Inbound/Collections/Category.php @@ -9,7 +9,7 @@ class Category extends BaseList protected function getIds(Datum $datum) { - return [ + return [ 'lake_uid' => $datum->id, ]; } diff --git a/app/Transformers/Inbound/Collections/Term.php b/app/Transformers/Inbound/Collections/Term.php index dcef2cd8..5b8ae6d8 100644 --- a/app/Transformers/Inbound/Collections/Term.php +++ b/app/Transformers/Inbound/Collections/Term.php @@ -11,7 +11,7 @@ class Term extends BaseList protected function getIds(Datum $datum) { - return [ + return [ 'lake_uid' => $datum->id, ]; } diff --git a/app/Transformers/Inbound/CollectionsTransformer.php b/app/Transformers/Inbound/CollectionsTransformer.php index 48294315..f6f507a5 100644 --- a/app/Transformers/Inbound/CollectionsTransformer.php +++ b/app/Transformers/Inbound/CollectionsTransformer.php @@ -9,7 +9,7 @@ class CollectionsTransformer extends BaseTransformer protected function getIds(Datum $datum) { - return [ + return [ 'citi_id' => $datum->id, ]; } diff --git a/app/Transformers/Inbound/Web/Experience.php b/app/Transformers/Inbound/Web/Experience.php index eb66cfe2..e46f3dd9 100644 --- a/app/Transformers/Inbound/Web/Experience.php +++ b/app/Transformers/Inbound/Web/Experience.php @@ -2,7 +2,6 @@ namespace App\Transformers\Inbound\Web; -use App\Transformers\Datum; use App\Transformers\Inbound\WebTransformer; class Experience extends WebTransformer diff --git a/app/Transformers/Inbound/Web/InteractiveFeature.php b/app/Transformers/Inbound/Web/InteractiveFeature.php index 33926b47..238a5a19 100644 --- a/app/Transformers/Inbound/Web/InteractiveFeature.php +++ b/app/Transformers/Inbound/Web/InteractiveFeature.php @@ -2,7 +2,6 @@ namespace App\Transformers\Inbound\Web; -use App\Transformers\Datum; use App\Transformers\Inbound\WebTransformer; class InteractiveFeature extends WebTransformer diff --git a/app/Transformers/Outbound/Collections/ArtworkManifest.php b/app/Transformers/Outbound/Collections/ArtworkManifest.php index 28052961..8de537c6 100644 --- a/app/Transformers/Outbound/Collections/ArtworkManifest.php +++ b/app/Transformers/Outbound/Collections/ArtworkManifest.php @@ -27,10 +27,10 @@ public function transform(Artwork $model) '@type' => 'sc:Manifest', 'label' => $model->title, 'description' => [ - [ - 'value' => strip_tags($model->description), - 'language' => 'en' - ] + [ + 'value' => strip_tags($model->description), + 'language' => 'en' + ] ], 'metadata' => [ [ @@ -89,7 +89,7 @@ private function _createCanvasImage($model, $image) return [ '@type' => 'sc:Canvas', '@id' => config('aic.config_documentation.iiif_url') . '/' . $imageUuid, - 'label' => strip_tags($model->title.', '.$model->date_display.'. '.str_replace("\n", ', ', $model->artist_display)), + 'label' => strip_tags($model->title . ', ' . $model->date_display . '. ' . str_replace("\n", ', ', $model->artist_display)), 'width' => $width, 'height' => $height, 'images' => [ diff --git a/app/Transformers/Outbound/Shop/Product.php b/app/Transformers/Outbound/Shop/Product.php index 70dd08fb..208a93c3 100644 --- a/app/Transformers/Outbound/Shop/Product.php +++ b/app/Transformers/Outbound/Shop/Product.php @@ -50,7 +50,7 @@ protected function getFields() $out = '

'; if ($item->min_current_price < $item->max_current_price) { - $out .= 'From '; + $out .= 'From '; } $out .= '$' . $item->min_current_price; diff --git a/config/filesystems.php b/config/filesystems.php index 565b0a06..af13286d 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -75,5 +75,4 @@ public_path('storage') => storage_path('app/public'), ], - ]; diff --git a/config/logging.php b/config/logging.php index fc8fb11e..19f7f908 100644 --- a/config/logging.php +++ b/config/logging.php @@ -2,7 +2,6 @@ use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; -use Monolog\Handler\SyslogUdpHandler; return [ /* diff --git a/config/resources/outbound.php b/config/resources/outbound.php index 20683ed8..eab5a7d2 100644 --- a/config/resources/outbound.php +++ b/config/resources/outbound.php @@ -288,7 +288,6 @@ 'no_dump' => true, ], - /** * Website: */ diff --git a/config/sanctum.php b/config/sanctum.php index 442726a7..3c92b7ae 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -16,7 +16,7 @@ 'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( '%s%s', 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', - env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' + env('APP_URL') ? ',' . parse_url(env('APP_URL'), PHP_URL_HOST) : '' ))), /* diff --git a/config/sentry.php b/config/sentry.php index 08451c89..0653bfb8 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -1,7 +1,7 @@ env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), + 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), // capture release as git sha // 'release' => trim(exec('git log --pretty="%h" -n1 HEAD')), @@ -49,7 +49,7 @@ // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii 'send_default_pii' => false, - 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), + 'traces_sample_rate' => (float) (env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), ]; diff --git a/database/factories/Membership/MembershipFactory.php b/database/factories/Membership/MembershipFactory.php index 04534c0f..c64647c1 100644 --- a/database/factories/Membership/MembershipFactory.php +++ b/database/factories/Membership/MembershipFactory.php @@ -22,25 +22,26 @@ public function membershipDates() 'source_modified_at' => $this->faker->dateTimeThisYear, ]; } -} -$factory->define(App\Models\Membership\TicketedEvent::class, function (Faker\Generator $this->faker) { - $has_capacity = rand(0, 1) === 1; + public function definition() + { + $has_capacity = rand(0, 1) === 1; - return array_merge( - $this->membershipIdsAndTitle(), - [ - 'image_url' => $this->faker->imageUrl, - 'start_at' => $this->faker->dateTimeThisYear, - 'end_at' => $this->faker->dateTimeThisYear, - 'resource_id' => $this->faker->randomNumber(2), - 'resource_title' => ucfirst($this->faker->words(3, true)), - 'is_after_hours' => $this->faker->boolean, - 'is_private_event' => $this->faker->boolean, - 'is_admission_required' => $this->faker->boolean, - 'available' => $has_capacity ? $this->faker->randomDigit * 10 : null, - 'total_capacity' => $has_capacity ? $this->faker->randomDigit * 100 : null, - ], - $this->membershipDates() - ); -}); + return array_merge( + $this->membershipIdsAndTitle(), + [ + 'image_url' => $this->faker->imageUrl, + 'start_at' => $this->faker->dateTimeThisYear, + 'end_at' => $this->faker->dateTimeThisYear, + 'resource_id' => $this->faker->randomNumber(2), + 'resource_title' => ucfirst($this->faker->words(3, true)), + 'is_after_hours' => $this->faker->boolean, + 'is_private_event' => $this->faker->boolean, + 'is_admission_required' => $this->faker->boolean, + 'available' => $has_capacity ? $this->faker->randomDigit * 10 : null, + 'total_capacity' => $has_capacity ? $this->faker->randomDigit * 100 : null, + ], + $this->membershipDates() + ); + } +} diff --git a/database/migrations/2020_02_04_142531_remove_copyright_notice_from_assets.php b/database/migrations/2020_02_04_142531_remove_copyright_notice_from_assets.php index 3f8e62d1..9643563c 100644 --- a/database/migrations/2020_02_04_142531_remove_copyright_notice_from_assets.php +++ b/database/migrations/2020_02_04_142531_remove_copyright_notice_from_assets.php @@ -13,7 +13,6 @@ public function up() }); } - public function down() { Schema::table('assets', function (Blueprint $table) { diff --git a/database/migrations/2021_05_23_120928_remove_qless_queues.php b/database/migrations/2021_05_23_120928_remove_qless_queues.php index 700117dc..80717685 100644 --- a/database/migrations/2021_05_23_120928_remove_qless_queues.php +++ b/database/migrations/2021_05_23_120928_remove_qless_queues.php @@ -13,7 +13,7 @@ class RemoveQlessQueues extends Migration */ public function up() { - WaitTime::destroy(1980,1981,1982,1983); + WaitTime::destroy(1980, 1981, 1982, 1983); } /** diff --git a/database/migrations/2021_09_20_125600_rename_selections_to_highlights.php b/database/migrations/2021_09_20_125600_rename_selections_to_highlights.php index 23737c1e..bdc077b3 100644 --- a/database/migrations/2021_09_20_125600_rename_selections_to_highlights.php +++ b/database/migrations/2021_09_20_125600_rename_selections_to_highlights.php @@ -1,7 +1,6 @@ it_fetches_fields( [ - 'id', - 'title', - 'image_id', - 'main_reference_number', - 'thumbnail', + 'id', + 'title', + 'image_id', + 'main_reference_number', + 'thumbnail', ], [ - 'artist_pivots', + 'artist_pivots', ] ); } @@ -91,49 +89,49 @@ public function it_fetches_fields_used_on_website_artwork_detail_page() { $this->it_fetches_fields( [ - 'id', - 'title', - 'alt_titles', - 'artist_id', - 'artist_title', - 'artist_display', - 'classification_id', - 'alt_classification_ids', - 'classification_titles', - 'color', - 'copyright_notice', - 'credit_line', - 'date_start', - 'date_end', - 'date_qualifier_title', - 'department_id', - 'department_title', - 'dimensions', - 'gallery_id', - 'gallery_title', - 'fiscal_year_deaccession', - 'inscriptions', - 'is_on_view', - 'is_public_domain', - 'is_zoomable', - 'main_reference_number', - 'material_titles', - 'medium_display', - 'image_id', - 'alt_image_ids', - 'max_zoom_window_size', - 'place_of_origin', - 'style_id', - 'alt_style_ids', - 'style_titles', - 'subject_titles', - 'thumbnail', + 'id', + 'title', + 'alt_titles', + 'artist_id', + 'artist_title', + 'artist_display', + 'classification_id', + 'alt_classification_ids', + 'classification_titles', + 'color', + 'copyright_notice', + 'credit_line', + 'date_start', + 'date_end', + 'date_qualifier_title', + 'department_id', + 'department_title', + 'dimensions', + 'gallery_id', + 'gallery_title', + 'fiscal_year_deaccession', + 'inscriptions', + 'is_on_view', + 'is_public_domain', + 'is_zoomable', + 'main_reference_number', + 'material_titles', + 'medium_display', + 'image_id', + 'alt_image_ids', + 'max_zoom_window_size', + 'place_of_origin', + 'style_id', + 'alt_style_ids', + 'style_titles', + 'subject_titles', + 'thumbnail', ], [ - 'dates', - 'artist_pivots', - 'catalogue_pivots', - 'place_pivots', + 'dates', + 'artist_pivots', + 'catalogue_pivots', + 'place_pivots', ] ); } @@ -143,15 +141,15 @@ public function it_fetches_fields_used_on_website_artist_detail_page() { $this->it_fetches_fields( [ - 'id', - 'image_id', - 'main_reference_number', - 'title', - 'thumbnail', - 'artist_title', + 'id', + 'image_id', + 'main_reference_number', + 'title', + 'thumbnail', + 'artist_title', ], [ - 'artist_pivots', + 'artist_pivots', ] ); } diff --git a/tests/Contract/ContractTestCase.php b/tests/Contract/ContractTestCase.php index 03115b41..b2a7916b 100644 --- a/tests/Contract/ContractTestCase.php +++ b/tests/Contract/ContractTestCase.php @@ -4,9 +4,6 @@ use Tests\TestCase; -use App\Models\Collections\AgentType; -use App\Models\Collections\Agent; - abstract class ContractTestCase extends TestCase { /** @@ -48,7 +45,7 @@ protected function it_fetches_fields($fields = [], $pivots = []) $m = $this->model(); $models = $this->times(5)->make($m); - $response = $this->getJson('api/v1/' . $this->route($m) .($pivots ? '?includes=' .implode(',', $pivots) : '')); + $response = $this->getJson('api/v1/' . $this->route($m) . ($pivots ? '?includes=' . implode(',', $pivots) : '')); $response->assertSuccessful(); $resources = $response->json()['data']; diff --git a/tests/Contract/ExhibitionTest.php b/tests/Contract/ExhibitionTest.php index 36c1bccf..f9618fbb 100644 --- a/tests/Contract/ExhibitionTest.php +++ b/tests/Contract/ExhibitionTest.php @@ -3,8 +3,6 @@ namespace Tests\Contract; use App\Models\Collections\Exhibition; -use App\Models\Collections\Place; -use App\Models\Collections\Agent; class ExhibitionTest extends ContractTestCase { diff --git a/tests/Helpers/Factory.php b/tests/Helpers/Factory.php index df2bcf41..3862364c 100644 --- a/tests/Helpers/Factory.php +++ b/tests/Helpers/Factory.php @@ -2,8 +2,6 @@ namespace Tests\Helpers; -use Illuminate\Support\Str; - trait Factory { From 8e161025b3bc597c13ae558b47ae0dc76eab185f Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Wed, 2 Feb 2022 23:50:59 -0600 Subject: [PATCH 18/23] Remove repetitive PHPDoc from factories [API-258] --- .../factories/Archive/ArchiveImageFactory.php | 15 --------------- database/factories/Collections/AgentFactory.php | 10 ---------- .../factories/Collections/AgentRoleFactory.php | 10 ---------- .../factories/Collections/AgentTypeFactory.php | 10 ---------- .../Collections/ArtworkCatalogueFactory.php | 10 ---------- .../factories/Collections/ArtworkDateFactory.php | 10 ---------- .../Collections/ArtworkDateQualifierFactory.php | 10 ---------- database/factories/Collections/ArtworkFactory.php | 10 ---------- .../Collections/ArtworkPlaceQualifierFactory.php | 10 ---------- .../factories/Collections/ArtworkTermFactory.php | 10 ---------- .../factories/Collections/ArtworkTypeFactory.php | 10 ---------- database/factories/Collections/AssetFactory.php | 10 ---------- .../factories/Collections/CategoryFactory.php | 10 ---------- .../factories/Collections/ExhibitionFactory.php | 10 ---------- database/factories/Collections/GalleryFactory.php | 10 ---------- database/factories/Collections/ImageFactory.php | 10 ---------- database/factories/Collections/PlaceFactory.php | 10 ---------- database/factories/Collections/SoundFactory.php | 10 ---------- database/factories/Collections/TermFactory.php | 10 ---------- database/factories/Collections/TextFactory.php | 10 ---------- database/factories/Collections/VideoFactory.php | 10 ---------- database/factories/Dsc/PublicationFactory.php | 10 ---------- database/factories/Dsc/SectionFactory.php | 10 ---------- database/factories/Library/MaterialFactory.php | 10 ---------- database/factories/Library/TermFactory.php | 10 ---------- .../factories/Membership/TicketedEventFactory.php | 10 ---------- database/factories/Mobile/ArtworkFactory.php | 10 ---------- database/factories/Mobile/SoundFactory.php | 10 ---------- database/factories/Mobile/TourFactory.php | 10 ---------- database/factories/Mobile/TourStopFactory.php | 10 ---------- database/factories/Shop/ProductFactory.php | 10 ---------- database/factories/StaticArchive/SiteFactory.php | 10 ---------- database/factories/Web/ArticleFactory.php | 10 ---------- database/factories/Web/ArtistFactory.php | 10 ---------- database/factories/Web/ClosureFactory.php | 10 ---------- database/factories/Web/DigitalCatalogFactory.php | 10 ---------- .../factories/Web/EducatorResourceFactory.php | 10 ---------- database/factories/Web/EventFactory.php | 10 ---------- database/factories/Web/EventProgramFactory.php | 10 ---------- database/factories/Web/ExhibitionFactory.php | 10 ---------- database/factories/Web/GenericPageFactory.php | 10 ---------- database/factories/Web/HighlightFactory.php | 10 ---------- database/factories/Web/PressReleaseFactory.php | 10 ---------- database/factories/Web/PrintedCatalogFactory.php | 10 ---------- 44 files changed, 445 deletions(-) diff --git a/database/factories/Archive/ArchiveImageFactory.php b/database/factories/Archive/ArchiveImageFactory.php index e19b5703..ffa3de96 100644 --- a/database/factories/Archive/ArchiveImageFactory.php +++ b/database/factories/Archive/ArchiveImageFactory.php @@ -7,18 +7,8 @@ class ArchiveImageFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArchiveImage::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $id = $this->faker->unique()->randomNumber(6) + 999 * pow(10, 6); @@ -49,11 +39,6 @@ public function definition() ]; } - /** - * Indicate that the model's email address should be unverified. - * - * @return \Illuminate\Database\Eloquent\Factories\Factory - */ public function unverified() { return $this->state(function (array $attributes) { diff --git a/database/factories/Collections/AgentFactory.php b/database/factories/Collections/AgentFactory.php index 1f1b2a72..784664ad 100644 --- a/database/factories/Collections/AgentFactory.php +++ b/database/factories/Collections/AgentFactory.php @@ -7,18 +7,8 @@ class AgentFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Agent::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $first_name = $this->faker->firstName; diff --git a/database/factories/Collections/AgentRoleFactory.php b/database/factories/Collections/AgentRoleFactory.php index 45b65144..9886353d 100644 --- a/database/factories/Collections/AgentRoleFactory.php +++ b/database/factories/Collections/AgentRoleFactory.php @@ -6,18 +6,8 @@ class AgentRoleFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = AgentRole::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return $this->idsAndTitle($this->faker->words(3, true), true, 2); diff --git a/database/factories/Collections/AgentTypeFactory.php b/database/factories/Collections/AgentTypeFactory.php index 8d8dec50..5390b05e 100644 --- a/database/factories/Collections/AgentTypeFactory.php +++ b/database/factories/Collections/AgentTypeFactory.php @@ -6,18 +6,8 @@ class AgentTypeFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = AgentType::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return $this->idsAndTitle($this->faker->unique()->randomElement(['Individual', 'Corporate Body', $this->faker->words(2, true)]), true, 2); diff --git a/database/factories/Collections/ArtworkCatalogueFactory.php b/database/factories/Collections/ArtworkCatalogueFactory.php index 41182851..834f4c4b 100644 --- a/database/factories/Collections/ArtworkCatalogueFactory.php +++ b/database/factories/Collections/ArtworkCatalogueFactory.php @@ -6,18 +6,8 @@ class ArtworkCatalogueFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkCatalogue::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Collections/ArtworkDateFactory.php b/database/factories/Collections/ArtworkDateFactory.php index bcaf5575..06e2b4fd 100644 --- a/database/factories/Collections/ArtworkDateFactory.php +++ b/database/factories/Collections/ArtworkDateFactory.php @@ -6,18 +6,8 @@ class ArtworkDateFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkDate::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/ArtworkDateQualifierFactory.php b/database/factories/Collections/ArtworkDateQualifierFactory.php index 0402606b..95eef9c8 100644 --- a/database/factories/Collections/ArtworkDateQualifierFactory.php +++ b/database/factories/Collections/ArtworkDateQualifierFactory.php @@ -6,18 +6,8 @@ class ArtworkDateQualifierFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkDateQualifier::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return $this->idsAndTitle($this->faker->randomElement(['Made', 'Designed', 'Reconstructed', 'Published']), true, 2); diff --git a/database/factories/Collections/ArtworkFactory.php b/database/factories/Collections/ArtworkFactory.php index f11ce877..909b1592 100644 --- a/database/factories/Collections/ArtworkFactory.php +++ b/database/factories/Collections/ArtworkFactory.php @@ -10,18 +10,8 @@ class ArtworkFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Artwork::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $date_end = $this->faker->year; diff --git a/database/factories/Collections/ArtworkPlaceQualifierFactory.php b/database/factories/Collections/ArtworkPlaceQualifierFactory.php index 2a129a1d..9ef719a6 100644 --- a/database/factories/Collections/ArtworkPlaceQualifierFactory.php +++ b/database/factories/Collections/ArtworkPlaceQualifierFactory.php @@ -6,18 +6,8 @@ class ArtworkPlaceQualifierFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkPlaceQualifier::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return $this->idsAndTitle('Object ' . $this->faker->word(1) . ' in', true, 2); diff --git a/database/factories/Collections/ArtworkTermFactory.php b/database/factories/Collections/ArtworkTermFactory.php index 499872b5..24750255 100644 --- a/database/factories/Collections/ArtworkTermFactory.php +++ b/database/factories/Collections/ArtworkTermFactory.php @@ -6,18 +6,8 @@ class ArtworkTermFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkTerm::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Collections/ArtworkTypeFactory.php b/database/factories/Collections/ArtworkTypeFactory.php index dc6fafd7..7e0be69e 100644 --- a/database/factories/Collections/ArtworkTypeFactory.php +++ b/database/factories/Collections/ArtworkTypeFactory.php @@ -6,18 +6,8 @@ class ArtworkTypeFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = ArtworkType::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return $this->idsAndTitle($this->faker->randomElement(['Painting', 'Design', 'Drawing and ' . ucfirst($this->faker->word), ucfirst($this->faker->word) . ' Arts', 'Sculpture']), true, 2); diff --git a/database/factories/Collections/AssetFactory.php b/database/factories/Collections/AssetFactory.php index 92b17199..7106c43d 100644 --- a/database/factories/Collections/AssetFactory.php +++ b/database/factories/Collections/AssetFactory.php @@ -6,18 +6,8 @@ class AssetFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Asset::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/CategoryFactory.php b/database/factories/Collections/CategoryFactory.php index 1e77cabe..0887ee78 100644 --- a/database/factories/Collections/CategoryFactory.php +++ b/database/factories/Collections/CategoryFactory.php @@ -6,18 +6,8 @@ class CategoryFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Category::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/ExhibitionFactory.php b/database/factories/Collections/ExhibitionFactory.php index 7965172b..e1f0a09f 100644 --- a/database/factories/Collections/ExhibitionFactory.php +++ b/database/factories/Collections/ExhibitionFactory.php @@ -7,18 +7,8 @@ class ExhibitionFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Exhibition::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/GalleryFactory.php b/database/factories/Collections/GalleryFactory.php index e7199358..3645799f 100644 --- a/database/factories/Collections/GalleryFactory.php +++ b/database/factories/Collections/GalleryFactory.php @@ -6,18 +6,8 @@ class GalleryFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Gallery::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/ImageFactory.php b/database/factories/Collections/ImageFactory.php index 24c13935..a3f785bb 100644 --- a/database/factories/Collections/ImageFactory.php +++ b/database/factories/Collections/ImageFactory.php @@ -6,18 +6,8 @@ class ImageFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Image::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/PlaceFactory.php b/database/factories/Collections/PlaceFactory.php index c8841515..ab59ba1d 100644 --- a/database/factories/Collections/PlaceFactory.php +++ b/database/factories/Collections/PlaceFactory.php @@ -6,18 +6,8 @@ class PlaceFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Place::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/SoundFactory.php b/database/factories/Collections/SoundFactory.php index 8e1165e1..1751e437 100644 --- a/database/factories/Collections/SoundFactory.php +++ b/database/factories/Collections/SoundFactory.php @@ -6,18 +6,8 @@ class SoundFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Sound::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/TermFactory.php b/database/factories/Collections/TermFactory.php index 3f4b8cd4..22277bcf 100644 --- a/database/factories/Collections/TermFactory.php +++ b/database/factories/Collections/TermFactory.php @@ -6,18 +6,8 @@ class TermFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Term::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/TextFactory.php b/database/factories/Collections/TextFactory.php index a83778ae..e53312e3 100644 --- a/database/factories/Collections/TextFactory.php +++ b/database/factories/Collections/TextFactory.php @@ -6,18 +6,8 @@ class TextFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Text::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Collections/VideoFactory.php b/database/factories/Collections/VideoFactory.php index 93cbe8ae..4581124d 100644 --- a/database/factories/Collections/VideoFactory.php +++ b/database/factories/Collections/VideoFactory.php @@ -6,18 +6,8 @@ class VideoFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Video::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Dsc/PublicationFactory.php b/database/factories/Dsc/PublicationFactory.php index 204e956c..fa868061 100644 --- a/database/factories/Dsc/PublicationFactory.php +++ b/database/factories/Dsc/PublicationFactory.php @@ -6,18 +6,8 @@ class PublicationFactory extends DscFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Publication::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Dsc/SectionFactory.php b/database/factories/Dsc/SectionFactory.php index cdaba23b..9d34efe1 100644 --- a/database/factories/Dsc/SectionFactory.php +++ b/database/factories/Dsc/SectionFactory.php @@ -8,18 +8,8 @@ class SectionFactory extends DscFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Section::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Library/MaterialFactory.php b/database/factories/Library/MaterialFactory.php index 27c234ca..41ead446 100644 --- a/database/factories/Library/MaterialFactory.php +++ b/database/factories/Library/MaterialFactory.php @@ -7,18 +7,8 @@ class MaterialFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Material::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $id = env('PRIMO_API_SOURCE') . '999' . $this->faker->unique()->randomNumber(8); diff --git a/database/factories/Library/TermFactory.php b/database/factories/Library/TermFactory.php index 5300b4b6..12389a5f 100644 --- a/database/factories/Library/TermFactory.php +++ b/database/factories/Library/TermFactory.php @@ -7,18 +7,8 @@ class TermFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Term::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $id = 'zz' . $this->faker->unique()->randomNumber(8); diff --git a/database/factories/Membership/TicketedEventFactory.php b/database/factories/Membership/TicketedEventFactory.php index 24bfe6bb..047ae4f6 100644 --- a/database/factories/Membership/TicketedEventFactory.php +++ b/database/factories/Membership/TicketedEventFactory.php @@ -6,18 +6,8 @@ class TicketedEventFactory extends MembershipFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = TicketedEvent::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $has_capacity = rand(0, 1) === 1; diff --git a/database/factories/Mobile/ArtworkFactory.php b/database/factories/Mobile/ArtworkFactory.php index 7cdb58b1..24003804 100644 --- a/database/factories/Mobile/ArtworkFactory.php +++ b/database/factories/Mobile/ArtworkFactory.php @@ -6,18 +6,8 @@ class ArtworkFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Artwork::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { static $artworks; diff --git a/database/factories/Mobile/SoundFactory.php b/database/factories/Mobile/SoundFactory.php index 8650f522..44d0f99e 100644 --- a/database/factories/Mobile/SoundFactory.php +++ b/database/factories/Mobile/SoundFactory.php @@ -6,18 +6,8 @@ class SoundFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Sound::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Mobile/TourFactory.php b/database/factories/Mobile/TourFactory.php index 209efe85..b4ed4dc7 100644 --- a/database/factories/Mobile/TourFactory.php +++ b/database/factories/Mobile/TourFactory.php @@ -7,18 +7,8 @@ class TourFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Tour::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Mobile/TourStopFactory.php b/database/factories/Mobile/TourStopFactory.php index 9b200016..2bcd8778 100644 --- a/database/factories/Mobile/TourStopFactory.php +++ b/database/factories/Mobile/TourStopFactory.php @@ -6,18 +6,8 @@ class TourStopFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = TourStop::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { static $artworks; diff --git a/database/factories/Shop/ProductFactory.php b/database/factories/Shop/ProductFactory.php index d315cb83..da85c333 100644 --- a/database/factories/Shop/ProductFactory.php +++ b/database/factories/Shop/ProductFactory.php @@ -6,18 +6,8 @@ class ProductFactory extends ShopFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Product::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { $part1 = ucwords($this->faker->words(2, true)); diff --git a/database/factories/StaticArchive/SiteFactory.php b/database/factories/StaticArchive/SiteFactory.php index 6c68e014..9f610cb3 100644 --- a/database/factories/StaticArchive/SiteFactory.php +++ b/database/factories/StaticArchive/SiteFactory.php @@ -7,18 +7,8 @@ class SiteFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Site::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/ArticleFactory.php b/database/factories/Web/ArticleFactory.php index 7bf6112f..06a612e5 100644 --- a/database/factories/Web/ArticleFactory.php +++ b/database/factories/Web/ArticleFactory.php @@ -7,18 +7,8 @@ class ArticleFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Article::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/ArtistFactory.php b/database/factories/Web/ArtistFactory.php index 2151b21b..daf16cf2 100644 --- a/database/factories/Web/ArtistFactory.php +++ b/database/factories/Web/ArtistFactory.php @@ -7,18 +7,8 @@ class ArtistFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Artist::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/ClosureFactory.php b/database/factories/Web/ClosureFactory.php index 66a14215..5ffffd6d 100644 --- a/database/factories/Web/ClosureFactory.php +++ b/database/factories/Web/ClosureFactory.php @@ -7,18 +7,8 @@ class ClosureFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Closure::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/DigitalCatalogFactory.php b/database/factories/Web/DigitalCatalogFactory.php index 4265b8aa..02aa3be2 100644 --- a/database/factories/Web/DigitalCatalogFactory.php +++ b/database/factories/Web/DigitalCatalogFactory.php @@ -7,18 +7,8 @@ class DigitalCatalogFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = DigitalCatalog::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/EducatorResourceFactory.php b/database/factories/Web/EducatorResourceFactory.php index f788576d..5b2a3cc7 100644 --- a/database/factories/Web/EducatorResourceFactory.php +++ b/database/factories/Web/EducatorResourceFactory.php @@ -7,18 +7,8 @@ class EducatorResourceFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = EducatorResource::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/EventFactory.php b/database/factories/Web/EventFactory.php index 9f04009e..a4e6ab66 100644 --- a/database/factories/Web/EventFactory.php +++ b/database/factories/Web/EventFactory.php @@ -7,18 +7,8 @@ class EventFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Event::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/EventProgramFactory.php b/database/factories/Web/EventProgramFactory.php index 0283d4da..36d154fb 100644 --- a/database/factories/Web/EventProgramFactory.php +++ b/database/factories/Web/EventProgramFactory.php @@ -7,18 +7,8 @@ class EventProgramFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = EventProgram::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/ExhibitionFactory.php b/database/factories/Web/ExhibitionFactory.php index 8f7de998..9ff799ad 100644 --- a/database/factories/Web/ExhibitionFactory.php +++ b/database/factories/Web/ExhibitionFactory.php @@ -7,18 +7,8 @@ class ExhibitionFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Exhibition::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/GenericPageFactory.php b/database/factories/Web/GenericPageFactory.php index d7c73ac5..52b65002 100644 --- a/database/factories/Web/GenericPageFactory.php +++ b/database/factories/Web/GenericPageFactory.php @@ -7,18 +7,8 @@ class GenericPageFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = GenericPage::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/HighlightFactory.php b/database/factories/Web/HighlightFactory.php index 2bf35bcf..198f085e 100644 --- a/database/factories/Web/HighlightFactory.php +++ b/database/factories/Web/HighlightFactory.php @@ -7,18 +7,8 @@ class HighlightFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = Highlight::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/PressReleaseFactory.php b/database/factories/Web/PressReleaseFactory.php index 91330c2e..ba658769 100644 --- a/database/factories/Web/PressReleaseFactory.php +++ b/database/factories/Web/PressReleaseFactory.php @@ -7,18 +7,8 @@ class PressReleaseFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = PressRelease::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ diff --git a/database/factories/Web/PrintedCatalogFactory.php b/database/factories/Web/PrintedCatalogFactory.php index 70bf83d8..aee10125 100644 --- a/database/factories/Web/PrintedCatalogFactory.php +++ b/database/factories/Web/PrintedCatalogFactory.php @@ -7,18 +7,8 @@ class PrintedCatalogFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ protected $model = PrintedCatalog::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ From c1c29ccc0e66ca6fd199586bca15403c4c8ec90f Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Thu, 3 Feb 2022 00:02:50 -0600 Subject: [PATCH 19/23] Inline factory model definitions [API-258] --- database/factories/Archive/ArchiveImageFactory.php | 3 +-- database/factories/Collections/AgentFactory.php | 3 +-- database/factories/Collections/AgentRoleFactory.php | 4 +--- database/factories/Collections/AgentTypeFactory.php | 4 +--- database/factories/Collections/ArtworkCatalogueFactory.php | 4 +--- database/factories/Collections/ArtworkDateFactory.php | 4 +--- .../factories/Collections/ArtworkDateQualifierFactory.php | 4 +--- database/factories/Collections/ArtworkFactory.php | 3 +-- .../factories/Collections/ArtworkPlaceQualifierFactory.php | 4 +--- database/factories/Collections/ArtworkTermFactory.php | 4 +--- database/factories/Collections/ArtworkTypeFactory.php | 4 +--- database/factories/Collections/AssetFactory.php | 4 +--- database/factories/Collections/ExhibitionFactory.php | 3 +-- database/factories/Collections/GalleryFactory.php | 4 +--- database/factories/Collections/ImageFactory.php | 4 +--- database/factories/Collections/PlaceFactory.php | 4 +--- database/factories/Collections/SoundFactory.php | 4 +--- database/factories/Collections/TermFactory.php | 4 +--- database/factories/Collections/TextFactory.php | 4 +--- database/factories/Collections/VideoFactory.php | 4 +--- database/factories/Dsc/PublicationFactory.php | 4 +--- database/factories/Library/MaterialFactory.php | 3 +-- database/factories/Library/TermFactory.php | 3 +-- database/factories/Membership/TicketedEventFactory.php | 4 +--- database/factories/Mobile/ArtworkFactory.php | 6 ++---- database/factories/Mobile/SoundFactory.php | 4 +--- database/factories/Mobile/TourFactory.php | 3 +-- database/factories/Mobile/TourStopFactory.php | 4 +--- database/factories/Shop/ProductFactory.php | 4 +--- database/factories/StaticArchive/SiteFactory.php | 3 +-- database/factories/Web/ArticleFactory.php | 3 +-- database/factories/Web/ArtistFactory.php | 3 +-- database/factories/Web/ClosureFactory.php | 3 +-- database/factories/Web/DigitalCatalogFactory.php | 3 +-- database/factories/Web/EducatorResourceFactory.php | 3 +-- database/factories/Web/EventFactory.php | 3 +-- database/factories/Web/EventProgramFactory.php | 3 +-- database/factories/Web/ExhibitionFactory.php | 3 +-- database/factories/Web/GenericPageFactory.php | 3 +-- database/factories/Web/HighlightFactory.php | 3 +-- database/factories/Web/PressReleaseFactory.php | 3 +-- database/factories/Web/PrintedCatalogFactory.php | 3 +-- 42 files changed, 43 insertions(+), 107 deletions(-) diff --git a/database/factories/Archive/ArchiveImageFactory.php b/database/factories/Archive/ArchiveImageFactory.php index ffa3de96..3bb66887 100644 --- a/database/factories/Archive/ArchiveImageFactory.php +++ b/database/factories/Archive/ArchiveImageFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Archive; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Archive\ArchiveImage; class ArchiveImageFactory extends Factory { - protected $model = ArchiveImage::class; + protected $model = \App\Models\Archive\ArchiveImage::class; public function definition() { diff --git a/database/factories/Collections/AgentFactory.php b/database/factories/Collections/AgentFactory.php index 784664ad..372d5125 100644 --- a/database/factories/Collections/AgentFactory.php +++ b/database/factories/Collections/AgentFactory.php @@ -2,12 +2,11 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Agent; use App\Models\Collections\AgentType; class AgentFactory extends CollectionsFactory { - protected $model = Agent::class; + protected $model = \App\Models\Collections\Agent::class; public function definition() { diff --git a/database/factories/Collections/AgentRoleFactory.php b/database/factories/Collections/AgentRoleFactory.php index 9886353d..70ad136e 100644 --- a/database/factories/Collections/AgentRoleFactory.php +++ b/database/factories/Collections/AgentRoleFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\AgentRole; - class AgentRoleFactory extends CollectionsFactory { - protected $model = AgentRole::class; + protected $model = \App\Models\Collections\AgentRole::class; public function definition() { diff --git a/database/factories/Collections/AgentTypeFactory.php b/database/factories/Collections/AgentTypeFactory.php index 5390b05e..9164cfce 100644 --- a/database/factories/Collections/AgentTypeFactory.php +++ b/database/factories/Collections/AgentTypeFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\AgentType; - class AgentTypeFactory extends CollectionsFactory { - protected $model = AgentType::class; + protected $model = \App\Models\Collections\AgentType::class; public function definition() { diff --git a/database/factories/Collections/ArtworkCatalogueFactory.php b/database/factories/Collections/ArtworkCatalogueFactory.php index 834f4c4b..dabcf864 100644 --- a/database/factories/Collections/ArtworkCatalogueFactory.php +++ b/database/factories/Collections/ArtworkCatalogueFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkCatalogue; - class ArtworkCatalogueFactory extends CollectionsFactory { - protected $model = ArtworkCatalogue::class; + protected $model = \App\Models\Collections\ArtworkCatalogue::class; public function definition() { diff --git a/database/factories/Collections/ArtworkDateFactory.php b/database/factories/Collections/ArtworkDateFactory.php index 06e2b4fd..29c614d9 100644 --- a/database/factories/Collections/ArtworkDateFactory.php +++ b/database/factories/Collections/ArtworkDateFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkDate; - class ArtworkDateFactory extends CollectionsFactory { - protected $model = ArtworkDate::class; + protected $model = \App\Models\Collections\ArtworkDate::class; public function definition() { diff --git a/database/factories/Collections/ArtworkDateQualifierFactory.php b/database/factories/Collections/ArtworkDateQualifierFactory.php index 95eef9c8..9982b574 100644 --- a/database/factories/Collections/ArtworkDateQualifierFactory.php +++ b/database/factories/Collections/ArtworkDateQualifierFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkDateQualifier; - class ArtworkDateQualifierFactory extends CollectionsFactory { - protected $model = ArtworkDateQualifier::class; + protected $model = \App\Models\Collections\ArtworkDateQualifier::class; public function definition() { diff --git a/database/factories/Collections/ArtworkFactory.php b/database/factories/Collections/ArtworkFactory.php index 909b1592..17c8ab56 100644 --- a/database/factories/Collections/ArtworkFactory.php +++ b/database/factories/Collections/ArtworkFactory.php @@ -2,7 +2,6 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Artwork; use App\Models\Collections\Agent; use App\Models\Collections\AgentType; use App\Models\Collections\ArtworkType; @@ -10,7 +9,7 @@ class ArtworkFactory extends CollectionsFactory { - protected $model = Artwork::class; + protected $model = \App\Models\Collections\Artwork::class; public function definition() { diff --git a/database/factories/Collections/ArtworkPlaceQualifierFactory.php b/database/factories/Collections/ArtworkPlaceQualifierFactory.php index 9ef719a6..719d6b75 100644 --- a/database/factories/Collections/ArtworkPlaceQualifierFactory.php +++ b/database/factories/Collections/ArtworkPlaceQualifierFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkPlaceQualifier; - class ArtworkPlaceQualifierFactory extends CollectionsFactory { - protected $model = ArtworkPlaceQualifier::class; + protected $model = \App\Models\Collections\ArtworkPlaceQualifier::class; public function definition() { diff --git a/database/factories/Collections/ArtworkTermFactory.php b/database/factories/Collections/ArtworkTermFactory.php index 24750255..001e99a0 100644 --- a/database/factories/Collections/ArtworkTermFactory.php +++ b/database/factories/Collections/ArtworkTermFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkTerm; - class ArtworkTermFactory extends CollectionsFactory { - protected $model = ArtworkTerm::class; + protected $model = \App\Models\Collections\ArtworkTerm::class; public function definition() { diff --git a/database/factories/Collections/ArtworkTypeFactory.php b/database/factories/Collections/ArtworkTypeFactory.php index 7e0be69e..269c2e9b 100644 --- a/database/factories/Collections/ArtworkTypeFactory.php +++ b/database/factories/Collections/ArtworkTypeFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkType; - class ArtworkTypeFactory extends CollectionsFactory { - protected $model = ArtworkType::class; + protected $model = \App\Models\Collections\ArtworkType::class; public function definition() { diff --git a/database/factories/Collections/AssetFactory.php b/database/factories/Collections/AssetFactory.php index 7106c43d..076238ed 100644 --- a/database/factories/Collections/AssetFactory.php +++ b/database/factories/Collections/AssetFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Asset; - class AssetFactory extends CollectionsFactory { - protected $model = Asset::class; + protected $model = \App\Models\Collections\Asset::class; public function definition() { diff --git a/database/factories/Collections/ExhibitionFactory.php b/database/factories/Collections/ExhibitionFactory.php index e1f0a09f..629aeb48 100644 --- a/database/factories/Collections/ExhibitionFactory.php +++ b/database/factories/Collections/ExhibitionFactory.php @@ -2,12 +2,11 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Exhibition; use App\Models\Collections\Place; class ExhibitionFactory extends CollectionsFactory { - protected $model = Exhibition::class; + protected $model = \App\Models\Collections\Exhibition::class; public function definition() { diff --git a/database/factories/Collections/GalleryFactory.php b/database/factories/Collections/GalleryFactory.php index 3645799f..db609bda 100644 --- a/database/factories/Collections/GalleryFactory.php +++ b/database/factories/Collections/GalleryFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Gallery; - class GalleryFactory extends CollectionsFactory { - protected $model = Gallery::class; + protected $model = \App\Models\Collections\Gallery::class; public function definition() { diff --git a/database/factories/Collections/ImageFactory.php b/database/factories/Collections/ImageFactory.php index a3f785bb..5673c459 100644 --- a/database/factories/Collections/ImageFactory.php +++ b/database/factories/Collections/ImageFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Image; - class ImageFactory extends AssetFactory { - protected $model = Image::class; + protected $model = \App\Models\Collections\Image::class; public function definition() { diff --git a/database/factories/Collections/PlaceFactory.php b/database/factories/Collections/PlaceFactory.php index ab59ba1d..45e4de6c 100644 --- a/database/factories/Collections/PlaceFactory.php +++ b/database/factories/Collections/PlaceFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Place; - class PlaceFactory extends CollectionsFactory { - protected $model = Place::class; + protected $model = \App\Models\Collections\Place::class; public function definition() { diff --git a/database/factories/Collections/SoundFactory.php b/database/factories/Collections/SoundFactory.php index 1751e437..a63ee47e 100644 --- a/database/factories/Collections/SoundFactory.php +++ b/database/factories/Collections/SoundFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Sound; - class SoundFactory extends AssetFactory { - protected $model = Sound::class; + protected $model = \App\Models\Collections\Sound::class; public function definition() { diff --git a/database/factories/Collections/TermFactory.php b/database/factories/Collections/TermFactory.php index 22277bcf..82991475 100644 --- a/database/factories/Collections/TermFactory.php +++ b/database/factories/Collections/TermFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Term; - class TermFactory extends CollectionsFactory { - protected $model = Term::class; + protected $model = \App\Models\Collections\Term::class; public function definition() { diff --git a/database/factories/Collections/TextFactory.php b/database/factories/Collections/TextFactory.php index e53312e3..1ee90bb0 100644 --- a/database/factories/Collections/TextFactory.php +++ b/database/factories/Collections/TextFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Text; - class TextFactory extends AssetFactory { - protected $model = Text::class; + protected $model = \App\Models\Collections\Text::class; public function definition() { diff --git a/database/factories/Collections/VideoFactory.php b/database/factories/Collections/VideoFactory.php index 4581124d..d3b37e56 100644 --- a/database/factories/Collections/VideoFactory.php +++ b/database/factories/Collections/VideoFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Video; - class VideoFactory extends AssetFactory { - protected $model = Video::class; + protected $model = \App\Models\Collections\Video::class; public function definition() { diff --git a/database/factories/Dsc/PublicationFactory.php b/database/factories/Dsc/PublicationFactory.php index fa868061..a0411b00 100644 --- a/database/factories/Dsc/PublicationFactory.php +++ b/database/factories/Dsc/PublicationFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Dsc; -use App\Models\Dsc\Publication; - class PublicationFactory extends DscFactory { - protected $model = Publication::class; + protected $model = \App\Models\Dsc\Publication::class; public function definition() { diff --git a/database/factories/Library/MaterialFactory.php b/database/factories/Library/MaterialFactory.php index 41ead446..ad120bf5 100644 --- a/database/factories/Library/MaterialFactory.php +++ b/database/factories/Library/MaterialFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Library; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Library\Material; class MaterialFactory extends Factory { - protected $model = Material::class; + protected $model = \App\Models\Library\Material::class; public function definition() { diff --git a/database/factories/Library/TermFactory.php b/database/factories/Library/TermFactory.php index 12389a5f..103138dd 100644 --- a/database/factories/Library/TermFactory.php +++ b/database/factories/Library/TermFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Library; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Library\Term; class TermFactory extends Factory { - protected $model = Term::class; + protected $model = \App\Models\Library\Term::class; public function definition() { diff --git a/database/factories/Membership/TicketedEventFactory.php b/database/factories/Membership/TicketedEventFactory.php index 047ae4f6..8ef65a66 100644 --- a/database/factories/Membership/TicketedEventFactory.php +++ b/database/factories/Membership/TicketedEventFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Membership; -use App\Models\Membership\TicketedEvent; - class TicketedEventFactory extends MembershipFactory { - protected $model = TicketedEvent::class; + protected $model = \App\Models\Membership\TicketedEvent::class; public function definition() { diff --git a/database/factories/Mobile/ArtworkFactory.php b/database/factories/Mobile/ArtworkFactory.php index 24003804..60f3c388 100644 --- a/database/factories/Mobile/ArtworkFactory.php +++ b/database/factories/Mobile/ArtworkFactory.php @@ -2,18 +2,16 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Artwork; - class ArtworkFactory extends MobileFactory { - protected $model = Artwork::class; + protected $model = \App\Models\Mobile\Artwork::class; public function definition() { static $artworks; if (!$artworks) { - $artworks = App\Models\Collections\Artwork::query()->pluck('citi_id')->all(); + $artworks = \App\Models\Collections\Artwork::query()->pluck('citi_id')->all(); } return array_merge( diff --git a/database/factories/Mobile/SoundFactory.php b/database/factories/Mobile/SoundFactory.php index 44d0f99e..da06413a 100644 --- a/database/factories/Mobile/SoundFactory.php +++ b/database/factories/Mobile/SoundFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Sound; - class SoundFactory extends MobileFactory { - protected $model = Sound::class; + protected $model = \App\Models\Mobile\Sound::class; public function definition() { diff --git a/database/factories/Mobile/TourFactory.php b/database/factories/Mobile/TourFactory.php index b4ed4dc7..5aa1d38f 100644 --- a/database/factories/Mobile/TourFactory.php +++ b/database/factories/Mobile/TourFactory.php @@ -2,12 +2,11 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Tour; use App\Models\Mobile\Sound; class TourFactory extends MobileFactory { - protected $model = Tour::class; + protected $model = \App\Models\Mobile\Tour::class; public function definition() { diff --git a/database/factories/Mobile/TourStopFactory.php b/database/factories/Mobile/TourStopFactory.php index 2bcd8778..fa87771c 100644 --- a/database/factories/Mobile/TourStopFactory.php +++ b/database/factories/Mobile/TourStopFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\TourStop; - class TourStopFactory extends MobileFactory { - protected $model = TourStop::class; + protected $model = \App\Models\Mobile\TourStop::class; public function definition() { diff --git a/database/factories/Shop/ProductFactory.php b/database/factories/Shop/ProductFactory.php index da85c333..aa7c9bd9 100644 --- a/database/factories/Shop/ProductFactory.php +++ b/database/factories/Shop/ProductFactory.php @@ -2,11 +2,9 @@ namespace Database\Factories\Shop; -use App\Models\Shop\Product; - class ProductFactory extends ShopFactory { - protected $model = Product::class; + protected $model = \App\Models\Shop\Product::class; public function definition() { diff --git a/database/factories/StaticArchive/SiteFactory.php b/database/factories/StaticArchive/SiteFactory.php index 9f610cb3..bb034727 100644 --- a/database/factories/StaticArchive/SiteFactory.php +++ b/database/factories/StaticArchive/SiteFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\StaticArchive; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\StaticArchive\Site; class SiteFactory extends Factory { - protected $model = Site::class; + protected $model = \App\Models\StaticArchive\Site::class; public function definition() { diff --git a/database/factories/Web/ArticleFactory.php b/database/factories/Web/ArticleFactory.php index 06a612e5..66748116 100644 --- a/database/factories/Web/ArticleFactory.php +++ b/database/factories/Web/ArticleFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Article; class ArticleFactory extends Factory { - protected $model = Article::class; + protected $model = \App\Models\Web\Article::class; public function definition() { diff --git a/database/factories/Web/ArtistFactory.php b/database/factories/Web/ArtistFactory.php index daf16cf2..988a77d0 100644 --- a/database/factories/Web/ArtistFactory.php +++ b/database/factories/Web/ArtistFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Artist; class ArtistFactory extends Factory { - protected $model = Artist::class; + protected $model = \App\Models\Web\Artist::class; public function definition() { diff --git a/database/factories/Web/ClosureFactory.php b/database/factories/Web/ClosureFactory.php index 5ffffd6d..cad39af1 100644 --- a/database/factories/Web/ClosureFactory.php +++ b/database/factories/Web/ClosureFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Closure; class ClosureFactory extends Factory { - protected $model = Closure::class; + protected $model = \App\Models\Web\Closure::class; public function definition() { diff --git a/database/factories/Web/DigitalCatalogFactory.php b/database/factories/Web/DigitalCatalogFactory.php index 02aa3be2..f6cef578 100644 --- a/database/factories/Web/DigitalCatalogFactory.php +++ b/database/factories/Web/DigitalCatalogFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\DigitalCatalog; class DigitalCatalogFactory extends Factory { - protected $model = DigitalCatalog::class; + protected $model = \App\Models\Web\DigitalCatalog::class; public function definition() { diff --git a/database/factories/Web/EducatorResourceFactory.php b/database/factories/Web/EducatorResourceFactory.php index 5b2a3cc7..001abaf1 100644 --- a/database/factories/Web/EducatorResourceFactory.php +++ b/database/factories/Web/EducatorResourceFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\EducatorResource; class EducatorResourceFactory extends Factory { - protected $model = EducatorResource::class; + protected $model = \App\Models\Web\EducatorResource::class; public function definition() { diff --git a/database/factories/Web/EventFactory.php b/database/factories/Web/EventFactory.php index a4e6ab66..b2ce67c1 100644 --- a/database/factories/Web/EventFactory.php +++ b/database/factories/Web/EventFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Event; class EventFactory extends Factory { - protected $model = Event::class; + protected $model = \App\Models\Web\Event::class; public function definition() { diff --git a/database/factories/Web/EventProgramFactory.php b/database/factories/Web/EventProgramFactory.php index 36d154fb..008e77f3 100644 --- a/database/factories/Web/EventProgramFactory.php +++ b/database/factories/Web/EventProgramFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\EventProgram; class EventProgramFactory extends Factory { - protected $model = EventProgram::class; + protected $model = \App\Models\Web\EventProgram::class; public function definition() { diff --git a/database/factories/Web/ExhibitionFactory.php b/database/factories/Web/ExhibitionFactory.php index 9ff799ad..11c758a2 100644 --- a/database/factories/Web/ExhibitionFactory.php +++ b/database/factories/Web/ExhibitionFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Exhibition; class ExhibitionFactory extends Factory { - protected $model = Exhibition::class; + protected $model = \App\Models\Web\Exhibition::class; public function definition() { diff --git a/database/factories/Web/GenericPageFactory.php b/database/factories/Web/GenericPageFactory.php index 52b65002..226675ed 100644 --- a/database/factories/Web/GenericPageFactory.php +++ b/database/factories/Web/GenericPageFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\GenericPage; class GenericPageFactory extends Factory { - protected $model = GenericPage::class; + protected $model = \App\Models\Web\GenericPage::class; public function definition() { diff --git a/database/factories/Web/HighlightFactory.php b/database/factories/Web/HighlightFactory.php index 198f085e..e42b896d 100644 --- a/database/factories/Web/HighlightFactory.php +++ b/database/factories/Web/HighlightFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Highlight; class HighlightFactory extends Factory { - protected $model = Highlight::class; + protected $model = \App\Models\Web\Highlight::class; public function definition() { diff --git a/database/factories/Web/PressReleaseFactory.php b/database/factories/Web/PressReleaseFactory.php index ba658769..7c3e2eb8 100644 --- a/database/factories/Web/PressReleaseFactory.php +++ b/database/factories/Web/PressReleaseFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\PressRelease; class PressReleaseFactory extends Factory { - protected $model = PressRelease::class; + protected $model = \App\Models\Web\PressRelease::class; public function definition() { diff --git a/database/factories/Web/PrintedCatalogFactory.php b/database/factories/Web/PrintedCatalogFactory.php index aee10125..d4d303bb 100644 --- a/database/factories/Web/PrintedCatalogFactory.php +++ b/database/factories/Web/PrintedCatalogFactory.php @@ -3,11 +3,10 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\PrintedCatalog; class PrintedCatalogFactory extends Factory { - protected $model = PrintedCatalog::class; + protected $model = \App\Models\Web\PrintedCatalog::class; public function definition() { From 04d22e2f643045ce062bbe6ad9929d702f4c012f Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Thu, 3 Feb 2022 00:12:57 -0600 Subject: [PATCH 20/23] Remove id offsets in factories [API-258] --- database/factories/Archive/ArchiveImageFactory.php | 2 +- database/factories/Collections/AssetFactory.php | 2 +- database/factories/Collections/CategoryFactory.php | 2 +- database/factories/Collections/CollectionsFactory.php | 2 +- database/factories/Collections/TermFactory.php | 2 +- database/factories/Dsc/DscFactory.php | 2 +- database/factories/Dsc/SectionFactory.php | 2 -- database/factories/Library/MaterialFactory.php | 2 +- database/factories/Membership/MembershipFactory.php | 2 +- database/factories/Mobile/MobileFactory.php | 2 +- database/factories/Shop/ShopFactory.php | 2 +- database/factories/StaticArchive/SiteFactory.php | 2 +- database/factories/Web/ArticleFactory.php | 2 +- database/factories/Web/ArtistFactory.php | 4 ++-- database/factories/Web/ClosureFactory.php | 2 +- database/factories/Web/DigitalCatalogFactory.php | 2 +- database/factories/Web/EducatorResourceFactory.php | 2 +- database/factories/Web/EventFactory.php | 2 +- database/factories/Web/EventProgramFactory.php | 2 +- database/factories/Web/ExhibitionFactory.php | 2 +- database/factories/Web/GenericPageFactory.php | 2 +- database/factories/Web/HighlightFactory.php | 2 +- database/factories/Web/PressReleaseFactory.php | 2 +- database/factories/Web/PrintedCatalogFactory.php | 2 +- 24 files changed, 24 insertions(+), 26 deletions(-) diff --git a/database/factories/Archive/ArchiveImageFactory.php b/database/factories/Archive/ArchiveImageFactory.php index 3bb66887..2bbbe766 100644 --- a/database/factories/Archive/ArchiveImageFactory.php +++ b/database/factories/Archive/ArchiveImageFactory.php @@ -10,7 +10,7 @@ class ArchiveImageFactory extends Factory public function definition() { - $id = $this->faker->unique()->randomNumber(6) + 999 * pow(10, 6); + $id = $this->faker->unique()->randomNumber(6); return [ 'id' => $id, 'title' => ucfirst($this->faker->words(3, true)), diff --git a/database/factories/Collections/AssetFactory.php b/database/factories/Collections/AssetFactory.php index 076238ed..38678727 100644 --- a/database/factories/Collections/AssetFactory.php +++ b/database/factories/Collections/AssetFactory.php @@ -11,7 +11,7 @@ public function definition() return array_merge( $this->idsAndTitle(ucwords($this->faker->words(3, true))), [ - 'lake_guid' => '99999999-9999-9999-9999-999999' . $this->faker->randomNumber(6, true), + 'lake_guid' => $this->faker->uuid(), 'content' => $this->faker->url, 'published' => true, 'description' => $this->faker->paragraph(3), diff --git a/database/factories/Collections/CategoryFactory.php b/database/factories/Collections/CategoryFactory.php index 0887ee78..fd25bfbe 100644 --- a/database/factories/Collections/CategoryFactory.php +++ b/database/factories/Collections/CategoryFactory.php @@ -14,7 +14,7 @@ public function definition() $this->idsAndTitle(ucfirst($this->faker->word(3, true))), [ 'is_category' => true, - 'lake_uid' => 'PC-' . ($this->faker->unique()->randomNumber(6) + 999 * pow(10, 6)), + 'lake_uid' => 'PC-' . $this->faker->unique()->randomNumber(6), 'subtype' => $this->faker->randomElement(['CT-1', 'CT-3']), 'parent_id' => $this->faker->randomElement(Category::query()->pluck('lake_uid')->all()), ] diff --git a/database/factories/Collections/CollectionsFactory.php b/database/factories/Collections/CollectionsFactory.php index d6664d8a..f2e7c1c6 100644 --- a/database/factories/Collections/CollectionsFactory.php +++ b/database/factories/Collections/CollectionsFactory.php @@ -12,7 +12,7 @@ public function idsAndTitle($title, $citiField = false, $idLength = 6) if ($citiField) { $ret = [ - 'citi_id' => $this->faker->unique()->randomNumber($idLength) + 999 * pow(10, $idLength), + 'citi_id' => $this->faker->unique()->randomNumber($idLength), ]; } diff --git a/database/factories/Collections/TermFactory.php b/database/factories/Collections/TermFactory.php index 82991475..e530341f 100644 --- a/database/factories/Collections/TermFactory.php +++ b/database/factories/Collections/TermFactory.php @@ -12,7 +12,7 @@ public function definition() $this->idsAndTitle(ucfirst($this->faker->word(3, true))), [ 'is_category' => false, - 'lake_uid' => 'TM-' . ($this->faker->unique()->randomNumber(6) + 999 * pow(10, 6)), + 'lake_uid' => 'TM-' . $this->faker->unique()->randomNumber(6), 'subtype' => $this->faker->randomElement(['TT-1', 'TT-2', 'TT-3', 'TT-4', 'TT-5']), ] ); diff --git a/database/factories/Dsc/DscFactory.php b/database/factories/Dsc/DscFactory.php index e9aea9e0..e62d0d8d 100644 --- a/database/factories/Dsc/DscFactory.php +++ b/database/factories/Dsc/DscFactory.php @@ -10,7 +10,7 @@ abstract class DscFactory extends Factory public function dscIdsAndTitle($id = '') { return [ - 'dsc_id' => $id ?: $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'dsc_id' => $id ?: $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), ]; } diff --git a/database/factories/Dsc/SectionFactory.php b/database/factories/Dsc/SectionFactory.php index 9d34efe1..2a55bc3f 100644 --- a/database/factories/Dsc/SectionFactory.php +++ b/database/factories/Dsc/SectionFactory.php @@ -15,7 +15,6 @@ public function definition() return array_merge( $this->dscIdsAndTitle(), [ - 'web_url' => $this->faker->url, 'accession' => $this->faker->accession, 'revision' => rand(1230768000, 1483228800), // timestamp b/w 2009 and 2017 @@ -25,7 +24,6 @@ public function definition() 'publication_dsc_id' => $this->faker->randomElement(Publication::query()->pluck('dsc_id')->all()), 'artwork_citi_id' => $this->faker->randomElement(Artwork::query()->pluck('citi_id')->all()), 'content' => $this->faker->paragraphs(10, true), - ] ); } diff --git a/database/factories/Library/MaterialFactory.php b/database/factories/Library/MaterialFactory.php index ad120bf5..5f3016ad 100644 --- a/database/factories/Library/MaterialFactory.php +++ b/database/factories/Library/MaterialFactory.php @@ -10,7 +10,7 @@ class MaterialFactory extends Factory public function definition() { - $id = env('PRIMO_API_SOURCE') . '999' . $this->faker->unique()->randomNumber(8); + $id = env('PRIMO_API_SOURCE') . $this->faker->unique()->randomNumber(8); return [ 'id' => $id, 'title' => ucfirst($this->faker->words(3, true)), diff --git a/database/factories/Membership/MembershipFactory.php b/database/factories/Membership/MembershipFactory.php index c64647c1..2f8a2e8e 100644 --- a/database/factories/Membership/MembershipFactory.php +++ b/database/factories/Membership/MembershipFactory.php @@ -10,7 +10,7 @@ class MembershipFactory extends Factory public function membershipIdsAndTitle($title = '') { return [ - 'membership_id' => $this->faker->unique()->randomNumber(5) + 999 * pow(10, 5), + 'membership_id' => $this->faker->unique()->randomNumber(5), 'title' => $title ? $title : ucfirst($this->faker->words(3, true)), ]; } diff --git a/database/factories/Mobile/MobileFactory.php b/database/factories/Mobile/MobileFactory.php index edaaf5fc..4108c2d2 100644 --- a/database/factories/Mobile/MobileFactory.php +++ b/database/factories/Mobile/MobileFactory.php @@ -9,7 +9,7 @@ abstract class MobileFactory extends Factory public function mobileAppIdsAndTitle($title = '') { return [ - 'mobile_id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'mobile_id' => $this->faker->unique()->randomNumber(4), 'title' => $title ? $title : ucfirst($this->faker->words(3, true)), ]; } diff --git a/database/factories/Shop/ShopFactory.php b/database/factories/Shop/ShopFactory.php index 8deebdc9..fcac347d 100644 --- a/database/factories/Shop/ShopFactory.php +++ b/database/factories/Shop/ShopFactory.php @@ -9,7 +9,7 @@ abstract class ShopFactory extends Factory public function shopIdsAndTitle($title = '') { return [ - 'shop_id' => $this->faker->unique()->randomNumber(3) + 999 * pow(10, 3), + 'shop_id' => $this->faker->unique()->randomNumber(3), 'title' => $title ? $title : ucfirst($this->faker->words(5, true)), ]; } diff --git a/database/factories/StaticArchive/SiteFactory.php b/database/factories/StaticArchive/SiteFactory.php index bb034727..8ad14c42 100644 --- a/database/factories/StaticArchive/SiteFactory.php +++ b/database/factories/StaticArchive/SiteFactory.php @@ -11,7 +11,7 @@ class SiteFactory extends Factory public function definition() { return [ - 'site_id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'site_id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'description' => $this->faker->paragraph(5), 'web_url' => $this->faker->url, diff --git a/database/factories/Web/ArticleFactory.php b/database/factories/Web/ArticleFactory.php index 66748116..c2a0ff96 100644 --- a/database/factories/Web/ArticleFactory.php +++ b/database/factories/Web/ArticleFactory.php @@ -11,7 +11,7 @@ class ArticleFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/ArtistFactory.php b/database/factories/Web/ArtistFactory.php index 988a77d0..fd40b09c 100644 --- a/database/factories/Web/ArtistFactory.php +++ b/database/factories/Web/ArtistFactory.php @@ -11,9 +11,9 @@ class ArtistFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), - 'datahub_id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'datahub_id' => $this->faker->unique()->randomNumber(4), ]; } } diff --git a/database/factories/Web/ClosureFactory.php b/database/factories/Web/ClosureFactory.php index cad39af1..e49187c6 100644 --- a/database/factories/Web/ClosureFactory.php +++ b/database/factories/Web/ClosureFactory.php @@ -11,7 +11,7 @@ class ClosureFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'date_start' => $this->faker->date(), 'date_end' => $this->faker->date(), diff --git a/database/factories/Web/DigitalCatalogFactory.php b/database/factories/Web/DigitalCatalogFactory.php index f6cef578..b5785678 100644 --- a/database/factories/Web/DigitalCatalogFactory.php +++ b/database/factories/Web/DigitalCatalogFactory.php @@ -11,7 +11,7 @@ class DigitalCatalogFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/EducatorResourceFactory.php b/database/factories/Web/EducatorResourceFactory.php index 001abaf1..2ff07897 100644 --- a/database/factories/Web/EducatorResourceFactory.php +++ b/database/factories/Web/EducatorResourceFactory.php @@ -11,7 +11,7 @@ class EducatorResourceFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/EventFactory.php b/database/factories/Web/EventFactory.php index b2ce67c1..6f35edce 100644 --- a/database/factories/Web/EventFactory.php +++ b/database/factories/Web/EventFactory.php @@ -11,7 +11,7 @@ class EventFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'is_private' => false, 'published' => true, diff --git a/database/factories/Web/EventProgramFactory.php b/database/factories/Web/EventProgramFactory.php index 008e77f3..1267ba97 100644 --- a/database/factories/Web/EventProgramFactory.php +++ b/database/factories/Web/EventProgramFactory.php @@ -11,7 +11,7 @@ class EventProgramFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), ]; } diff --git a/database/factories/Web/ExhibitionFactory.php b/database/factories/Web/ExhibitionFactory.php index 11c758a2..c8ba21f8 100644 --- a/database/factories/Web/ExhibitionFactory.php +++ b/database/factories/Web/ExhibitionFactory.php @@ -14,7 +14,7 @@ public function definition() 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'is_published' => true, - 'datahub_id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'datahub_id' => $this->faker->unique()->randomNumber(4), ]; } } diff --git a/database/factories/Web/GenericPageFactory.php b/database/factories/Web/GenericPageFactory.php index 226675ed..015469dc 100644 --- a/database/factories/Web/GenericPageFactory.php +++ b/database/factories/Web/GenericPageFactory.php @@ -11,7 +11,7 @@ class GenericPageFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/HighlightFactory.php b/database/factories/Web/HighlightFactory.php index e42b896d..a1210b9e 100644 --- a/database/factories/Web/HighlightFactory.php +++ b/database/factories/Web/HighlightFactory.php @@ -11,7 +11,7 @@ class HighlightFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/PressReleaseFactory.php b/database/factories/Web/PressReleaseFactory.php index 7c3e2eb8..3d359cec 100644 --- a/database/factories/Web/PressReleaseFactory.php +++ b/database/factories/Web/PressReleaseFactory.php @@ -11,7 +11,7 @@ class PressReleaseFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; diff --git a/database/factories/Web/PrintedCatalogFactory.php b/database/factories/Web/PrintedCatalogFactory.php index d4d303bb..ebdc29cc 100644 --- a/database/factories/Web/PrintedCatalogFactory.php +++ b/database/factories/Web/PrintedCatalogFactory.php @@ -11,7 +11,7 @@ class PrintedCatalogFactory extends Factory public function definition() { return [ - 'id' => $this->faker->unique()->randomNumber(4) + 999 * pow(10, 4), + 'id' => $this->faker->unique()->randomNumber(4), 'title' => ucfirst($this->faker->words(3, true)), 'published' => true, ]; From 0933ba56bb5d971c102ddd39bb983b8d55ab826b Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Thu, 3 Feb 2022 13:53:48 -0600 Subject: [PATCH 21/23] Enable Redis [API-256] --- config/app.php | 2 +- config/cache.php | 2 +- config/database.php | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config/app.php b/config/app.php index 930a9c3b..bba8ad19 100644 --- a/config/app.php +++ b/config/app.php @@ -229,7 +229,7 @@ 'Queue' => Illuminate\Support\Facades\Queue::class, 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, - // 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, diff --git a/config/cache.php b/config/cache.php index 7d97cd71..a8d7e6b9 100644 --- a/config/cache.php +++ b/config/cache.php @@ -75,7 +75,7 @@ 'redis' => [ 'driver' => 'redis', - 'connection' => 'default', + 'connection' => 'cache', 'lock_connection' => 'default', ], diff --git a/config/database.php b/config/database.php index dcbe1e08..ea7f2dbb 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,7 @@ [ + 'sqlite' => [ 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => env('DB_PREFIX', ''), 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], + 'mysql' => [ 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), @@ -56,6 +62,7 @@ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], + 'testing' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), @@ -63,8 +70,10 @@ 'prefix' => env('DB_PREFIX', ''), 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], + 'pgsql' => [ 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), @@ -76,8 +85,10 @@ 'schema' => 'public', 'sslmode' => 'prefer', ], + 'sqlsrv' => [ 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), @@ -108,7 +119,7 @@ |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems + | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ @@ -119,9 +130,11 @@ 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ + 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), @@ -129,11 +142,13 @@ ], 'cache' => [ + 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), ], + ], ]; From 52692da3f9f7ea14592cccec4f44fb7f7810e270 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Tue, 8 Feb 2022 18:11:52 -0600 Subject: [PATCH 22/23] Update foundation to fix `make:user` [API-140, API-125] --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index b6a78a4b..7ad163cc 100644 --- a/composer.lock +++ b/composer.lock @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/art-institute-of-chicago/data-hub-foundation.git", - "reference": "91b6011e5d050aa900f6e6bba5be1cdae8cea7ab" + "reference": "dd83bcf6c32d25d958c7e9a6d376c16470e23dd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/art-institute-of-chicago/data-hub-foundation/zipball/91b6011e5d050aa900f6e6bba5be1cdae8cea7ab", - "reference": "91b6011e5d050aa900f6e6bba5be1cdae8cea7ab", + "url": "https://api.github.com/repos/art-institute-of-chicago/data-hub-foundation/zipball/dd83bcf6c32d25d958c7e9a6d376c16470e23dd8", + "reference": "dd83bcf6c32d25d958c7e9a6d376c16470e23dd8", "shasum": "" }, "require": { @@ -82,7 +82,7 @@ "source": "https://github.com/art-institute-of-chicago/data-hub-foundation/tree/laravel-8-support", "issues": "https://github.com/art-institute-of-chicago/data-hub-foundation/issues" }, - "time": "2022-02-03T05:31:46+00:00" + "time": "2022-02-09T00:08:14+00:00" }, { "name": "aic/laravel-scout-elastic", From 1530a38e69dcadeb1964ddf8306f41be8500eb10 Mon Sep 17 00:00:00 2001 From: Illya Moskvin Date: Thu, 10 Feb 2022 15:40:47 -0600 Subject: [PATCH 23/23] Bump version number --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5625e59d..7e32cd56 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2 +1.3