diff --git a/.env.example b/.env.example index a36052475..f01f0278e 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/.gitignore b/.gitignore index d0fd065f7..03c2d6955 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 9d2657efb..000000000 --- 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/VERSION b/VERSION index 5625e59da..7e32cd569 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2 +1.3 diff --git a/app/Console/Commands/Delete/DeleteAssets.php b/app/Console/Commands/Delete/DeleteAssets.php index f2a03b067..732255063 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 e80d51679..76495f06a 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 23a173359..7d5803611 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 0fac120de..46a400d0c 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 328928f80..e6445f1c4 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 a55ab87fd..b5da3f7c6 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 c6bc70ff0..a008e63ee 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 0e00c9b2c..8f3c03ad6 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 ce50b0ce5..ffc75c0a2 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 2f60086a0..faf02e6fd 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 d4329482a..07c2119e9 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 0cdf3a927..7c35ab0d2 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 = [ - // + ]; /** @@ -78,6 +76,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', [ + \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() diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 077490073..2358ad24e 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 dc0930941..c4cd1075f 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 c76a90525..646dcd876 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 9b7fda8d1..25b006a73 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 d4944d6cb..1254d0683 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 073477eb3..d3a73e6c4 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; @@ -30,20 +28,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 +124,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 +143,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 +216,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/app/Http/Middleware/DecodeParams.php b/app/Http/Middleware/DecodeParams.php index 8c4949440..29487a0ba 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 97c74e2e8..2dc798ca3 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 e4956d0bb..59d4cb066 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 4a81ae07d..45a1f70a1 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 c892817ad..0976e5d5e 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 9b143cfc3..7170092bd 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 0c13b8548..f1e650cd5 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 faccd1f5e..f5e3552ad 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; @@ -751,6 +750,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 +760,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 @@ -793,7 +793,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']), @@ -904,12 +904,17 @@ 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 ($isExact) { + return 0; + } + if (!isset($input['fuzzy'])) { return 'AUTO'; } diff --git a/app/Http/Search/Response.php b/app/Http/Search/Response.php index 8f3dc2478..16935934e 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; @@ -84,6 +83,12 @@ public function getSearchResponse() $response ); + $config = config('aic.config_documentation'); + + if ($config) { + $response['config'] = $config; + } + return $response; } @@ -215,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 baede4933..f0d9813c0 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/AbstractPivot.php b/app/Models/AbstractPivot.php index 43559ef3a..aec219b50 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 ea5c825ac..b1935fca9 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. @@ -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 d2518aff0..f675c8946 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 30403a911..88c9eeff6 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 9c04f3795..adb80be88 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 1381edde7..5adc497a7 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/ElasticSearchable.php b/app/Models/ElasticSearchable.php index dc3d12a39..6ee34a557 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/Models/Instancable.php b/app/Models/Instancable.php deleted file mode 100644 index c16fb82d2..000000000 --- a/app/Models/Instancable.php +++ /dev/null @@ -1,27 +0,0 @@ -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 a055e5036..9b44624e1 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 4ee926238..2dce1e963 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/Artwork.php b/app/Transformers/Inbound/Collections/Artwork.php index ba219a208..611b116bf 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/Inbound/Collections/Asset.php b/app/Transformers/Inbound/Collections/Asset.php index cdb4eec85..3e249fd36 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 2438ae137..70090e551 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 dcef2cd8b..5b8ae6d87 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 48294315d..f6f507a50 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 eb66cfe28..e46f3dd93 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 33926b472..238a5a19f 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/AbstractTransformer.php b/app/Transformers/Outbound/AbstractTransformer.php index 62f397b35..e942ddf0c 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, ], ], @@ -344,6 +345,41 @@ 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($hasKeyword = false, $customMapping = []) + { + $mapping = [ + 'type' => 'text', + 'fields' => [ + '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; + } + /** * Helper to parse out the fields variable passed via constructor. * Expects a comma-separated string or an array. @@ -388,6 +424,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 2a16c7f0a..7b9bab5de 100644 --- a/app/Transformers/Outbound/Collections/Agent.php +++ b/app/Transformers/Outbound/Collections/Agent.php @@ -35,18 +35,22 @@ 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', ], 'alt_titles' => [ 'doc' => 'Alternate names for this agent', 'type' => 'array', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', // For better search experiences with Korean, Chinese and Japanese queries. // See https://www.elastic.co/blog/how-to-search-ch-jp-kr-part-2 @@ -183,7 +187,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) { @@ -200,7 +204,7 @@ protected function getSuggestFields() $item->title, $item->sort_title, ], - $item->alt_titles ?? [] + array_filter($item->alt_titles ?? []) ), 'weight' => $item->isBoosted() ? 3 : 2, ]; @@ -213,7 +217,7 @@ protected function getSuggestFields() $item->title, $item->sort_title, ], - $item->alt_titles ?? [] + array_filter($item->alt_titles ?? []) ), 'weight' => $item->isBoosted() ? 3 : 2, 'contexts' => [ diff --git a/app/Transformers/Outbound/Collections/Artwork.php b/app/Transformers/Outbound/Collections/Artwork.php index 869395c4a..79e0f2481 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,8 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, + 'mapping' => $this->getDefaultStringMapping(true), 'boost' => 5, - 'type' => 'keyword', ], 'value' => function ($item) { return $item->main_id; @@ -172,7 +171,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'date_qualifier_title' => [ @@ -196,7 +194,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'place_of_origin' => [ @@ -205,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', @@ -222,7 +221,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'inscriptions' => [ @@ -235,7 +233,6 @@ protected function getFields() 'type' => 'string', 'elasticsearch' => [ 'default' => true, - 'type' => 'text', ], ], 'publication_history' => [ @@ -475,6 +472,9 @@ protected function getFields() 'artist_title' => [ 'doc' => 'Name of the preferred artist/culture associated with this work', 'type' => 'string', + 'elasticsearch' => [ + 'mapping' => $this->getDefaultStringMapping(true), + ], 'value' => function ($item) { return $item->artist->title ?? null; }, @@ -500,6 +500,7 @@ 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), ], diff --git a/app/Transformers/Outbound/Collections/ArtworkManifest.php b/app/Transformers/Outbound/Collections/ArtworkManifest.php index 280529615..8de537c69 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/Collections/Exhibition.php b/app/Transformers/Outbound/Collections/Exhibition.php index ffa70e5bc..3ee0872c5 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 2a9473a12..02a896656 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 ccedbed95..a7d866b67 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 e60688ab7..37b174340 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 67f93b997..d8d12e72f 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 e1aaeba2b..208a93c37 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' => [ @@ -51,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/app/Transformers/Outbound/StaticArchive/Site.php b/app/Transformers/Outbound/StaticArchive/Site.php index 657bbc74c..b6b27e467 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 18aba8784..2382876b9 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 d6c03eb77..ade0b6f3a 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 e70faec78..684e57d6b 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 8332560e4..b67dec179 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 b5192f000..b8cab076d 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 c8cdd85a6..674f6c8bb 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 978d909fd..c545dafe6 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/composer.json b/composer.json index 6b69e4196..6bf278a5b 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,12 @@ "name": "aic/api", "type": "project", "description": "Art Institute of Chicago Public API", - "keywords": ["api", "museum", "musetech", "art institute of chicago"], + "keywords": [ + "api", + "museum", + "musetech", + "art institute of chicago" + ], "license": "AGPL-3.0-or-later", "repositories": [ { @@ -38,15 +43,16 @@ "zendframework/zend-code": "^3.4" }, "require-dev": { + "brianium/paratest": "^6.4", "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", + "friendsofphp/php-cs-fixer": "^3.5", + "itsgoingd/clockwork": "^5.0", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", - "phpunit/phpunit": "^9.5.10", - "itsgoingd/clockwork": "^5.0", - "brianium/paratest": "^6.0", "phpstan/phpstan": "^1.0", + "phpunit/phpunit": "^9.5.10", "squizlabs/php_codesniffer": "^3.0" }, "autoload": { @@ -78,6 +84,14 @@ ], "post-create-project-cmd": [ "php artisan key:generate --ansi" + ], + "lint": [ + "php-cs-fixer fix --diff --config vendor/aic/data-hub-foundation/.php-cs-fixer.dist.php", + "DIR='vendor/aic/data-hub-foundation' && [ -L ${DIR} ] && [ -d ${DIR} ] && cd ${DIR} && php-cs-fixer fix --diff --config .php-cs-fixer.dist.php || true" + ], + "foundation": [ + "php vendor/aic/data-hub-foundation/composer-dev.php", + "COMPOSER=composer-dev.json composer update aic/data-hub-foundation" ] }, "extra": { @@ -88,6 +102,12 @@ "config": { "optimize-autoloader": true, "preferred-install": "dist", - "sort-packages": true - } + "sort-packages": true, + "allow-plugins": { + "ocramius/package-versions": true, + "netresearch/composer-patches-plugin": true + } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/composer.lock b/composer.lock index 32549fe73..7ad163ccc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5b9f6d0ddd26957c673142f5930eee4", + "content-hash": "4d064a17c93c009d67ff1933a6931991", "packages": [ { "name": "aic/data-hub-foundation", @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/art-institute-of-chicago/data-hub-foundation.git", - "reference": "69b1ba42cf3eb7156911fbe2d7783eb1cd03b126" + "reference": "dd83bcf6c32d25d958c7e9a6d376c16470e23dd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/art-institute-of-chicago/data-hub-foundation/zipball/69b1ba42cf3eb7156911fbe2d7783eb1cd03b126", - "reference": "69b1ba42cf3eb7156911fbe2d7783eb1cd03b126", + "url": "https://api.github.com/repos/art-institute-of-chicago/data-hub-foundation/zipball/dd83bcf6c32d25d958c7e9a6d376c16470e23dd8", + "reference": "dd83bcf6c32d25d958c7e9a6d376c16470e23dd8", "shasum": "" }, "require": { @@ -28,6 +28,10 @@ "netresearch/composer-patches-plugin": "~1.0", "php": "^7.3|^8.0" }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.5", + "vendor/package-patches-dev": "~1.0" + }, "type": "library", "extra": { "laravel": { @@ -41,6 +45,12 @@ "title": "API-227: Remove comments from migration stubs", "url": "vendor/aic/data-hub-foundation/patches/API-227---remove-comments-from-migration-stubs.diff" } + ], + "friendsofphp/php-cs-fixer": [ + { + "title": "API-45: Fix arrow functions in method_chaining_indentation", + "url": "vendor/aic/data-hub-foundation/patches/API-45---fix-arrow-functions-in-method-chaining-indentation.diff" + } ] } }, @@ -49,6 +59,11 @@ "Aic\\Hub\\Foundation\\": "src/" } }, + "scripts": { + "lint": [ + "php-cs-fixer fix --diff --config .php-cs-fixer.dist.php" + ] + }, "license": [ "AGPL-3.0" ], @@ -67,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": "2021-12-13T22:12:49+00:00" + "time": "2022-02-09T00:08:14+00:00" }, { "name": "aic/laravel-scout-elastic", @@ -290,12 +305,12 @@ } }, "autoload": { - "psr-4": { - "Aws\\": "src/" - }, "files": [ "src/functions.php" - ] + ], + "psr-4": { + "Aws\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1735,12 +1750,12 @@ } }, "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -8137,6 +8152,296 @@ ], "time": "2021-12-02T09:12:23+00:00" }, + { + "name": "composer/pcre", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/1.0.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-21T20:24:37+00:00" + }, + { + "name": "composer/semver", + "version": "3.2.7", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "deac27056b57e46faf136fae7b449eeaa71661ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee", + "reference": "deac27056b57e46faf136fae7b449eeaa71661ee", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.54", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.2.7" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-04T09:57:54+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "12f1b79476638a5615ed00ea6adbb269cec96fd8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/12f1b79476638a5615ed00ea6adbb269cec96fd8", + "reference": "12f1b79476638a5615ed00ea6adbb269cec96fd8", + "shasum": "" + }, + "require": { + "composer/pcre": "^1", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-04T18:29:42+00:00" + }, + { + "name": "doctrine/annotations", + "version": "1.13.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "5b668aef16090008790395c02c893b1ba13f7e08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5b668aef16090008790395c02c893b1ba13f7e08", + "reference": "5b668aef16090008790395c02c893b1ba13f7e08", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "ext-tokenizer": "*", + "php": "^7.1 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" + }, + "require-dev": { + "doctrine/cache": "^1.11 || ^2.0", + "doctrine/coding-standard": "^6.0 || ^8.1", + "phpstan/phpstan": "^0.12.20", + "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", + "symfony/cache": "^4.4 || ^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/1.13.2" + }, + "time": "2021-08-05T19:00:23+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.0", @@ -8404,16 +8709,16 @@ }, { "name": "fakerphp/faker", - "version": "v1.17.0", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "b85e9d44eae8c52cca7aa0939483611f7232b669" + "reference": "d7f08a622b3346766325488aa32ddc93ccdecc75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/b85e9d44eae8c52cca7aa0939483611f7232b669", - "reference": "b85e9d44eae8c52cca7aa0939483611f7232b669", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/d7f08a622b3346766325488aa32ddc93ccdecc75", + "reference": "d7f08a622b3346766325488aa32ddc93ccdecc75", "shasum": "" }, "require": { @@ -8426,10 +8731,12 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", "ext-intl": "*", "symfony/phpunit-bridge": "^4.4 || ^5.2" }, "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", "ext-curl": "Required by Faker\\Provider\\Image to download images.", "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", @@ -8438,7 +8745,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "v1.17-dev" + "dev-main": "v1.19-dev" } }, "autoload": { @@ -8463,9 +8770,9 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.17.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.19.0" }, - "time": "2021-12-05T17:14:47+00:00" + "time": "2022-02-02T17:38:57+00:00" }, { "name": "filp/whoops", @@ -8538,6 +8845,95 @@ ], "time": "2021-10-03T12:00:00+00:00" }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "333f15e07c866e33e2765e84ba1e0b88e6a3af3b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/333f15e07c866e33e2765e84ba1e0b88e6a3af3b", + "reference": "333f15e07c866e33e2765e84ba1e0b88e6a3af3b", + "shasum": "" + }, + "require": { + "composer/semver": "^3.2", + "composer/xdebug-handler": "^3.0", + "doctrine/annotations": "^1.13", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0", + "php-cs-fixer/diff": "^2.0", + "symfony/console": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/finder": "^5.4 || ^6.0", + "symfony/options-resolver": "^5.4 || ^6.0", + "symfony/polyfill-mbstring": "^1.23", + "symfony/polyfill-php80": "^1.23", + "symfony/polyfill-php81": "^1.23", + "symfony/process": "^5.4 || ^6.0", + "symfony/stopwatch": "^5.4 || ^6.0" + }, + "require-dev": { + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^1.5", + "mikey179/vfsstream": "^1.6.10", + "php-coveralls/php-coveralls": "^2.5.2", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.15", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.5", + "phpunitgoodpractices/traits": "^1.9.1", + "symfony/phpunit-bridge": "^6.0", + "symfony/yaml": "^5.4 || ^6.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "support": { + "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2022-01-14T00:29:20+00:00" + }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.1", @@ -8720,16 +9116,16 @@ }, { "name": "mockery/mockery", - "version": "1.4.4", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346" + "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/e01123a0e847d52d186c5eb4b9bf58b0c6d00346", - "reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346", + "url": "https://api.github.com/repos/mockery/mockery/zipball/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac", + "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac", "shasum": "" }, "require": { @@ -8786,9 +9182,9 @@ ], "support": { "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/1.4.4" + "source": "https://github.com/mockery/mockery/tree/1.5.0" }, - "time": "2021-09-13T15:28:59+00:00" + "time": "2022-01-20T13:18:17+00:00" }, { "name": "myclabs/deep-copy", @@ -8807,9 +9203,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -9046,6 +9439,58 @@ }, "time": "2021-02-23T14:00:09+00:00" }, + { + "name": "php-cs-fixer/diff", + "version": "v2.0.2", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3", + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "sebastian/diff v3 backport support for PHP 5.6+", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/diff/issues", + "source": "https://github.com/PHP-CS-Fixer/diff/tree/v2.0.2" + }, + "time": "2020-10-14T08:32:19+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -9758,6 +10203,55 @@ ], "time": "2021-09-25T07:38:51+00:00" }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=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" } diff --git a/config/app.php b/config/app.php index 930a9c3bc..bba8ad190 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 7d97cd71a..a8d7e6b92 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 dcbe1e08c..ea7f2dbbf 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'), ], + ], ]; diff --git a/config/elasticsearch.php b/config/elasticsearch.php index 2d3643792..221cbc81c 100644 --- a/config/elasticsearch.php +++ b/config/elasticsearch.php @@ -282,6 +282,15 @@ 'asciifolding', ], ], + 'exact' => [ + 'tokenizer' => 'standard', + 'filter' => [ + 'lowercase', + 'english_stop', + 'asciifolding', + 'shingle', + ], + ], ], ], ], @@ -290,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), - ]; diff --git a/config/filesystems.php b/config/filesystems.php index 565b0a06e..af13286d1 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 fc8fb11e4..19f7f9085 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 20683ed89..eab5a7d27 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 442726a7a..3c92b7ae2 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 08451c898..0653bfb89 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/Archive/ArchiveImageFactory.php b/database/factories/Archive/ArchiveImageFactory.php index e19b57038..2bbbe766f 100644 --- a/database/factories/Archive/ArchiveImageFactory.php +++ b/database/factories/Archive/ArchiveImageFactory.php @@ -3,25 +3,14 @@ namespace Database\Factories\Archive; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Archive\ArchiveImage; class ArchiveImageFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArchiveImage::class; + protected $model = \App\Models\Archive\ArchiveImage::class; - /** - * Define the model's default state. - * - * @return array - */ 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)), @@ -49,11 +38,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 1f1b2a722..372d51258 100644 --- a/database/factories/Collections/AgentFactory.php +++ b/database/factories/Collections/AgentFactory.php @@ -2,23 +2,12 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Agent; use App\Models\Collections\AgentType; class AgentFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Agent::class; + protected $model = \App\Models\Collections\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 45b651444..70ad136ea 100644 --- a/database/factories/Collections/AgentRoleFactory.php +++ b/database/factories/Collections/AgentRoleFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\AgentRole; - class AgentRoleFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = AgentRole::class; + protected $model = \App\Models\Collections\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 8d8dec50a..9164cfcec 100644 --- a/database/factories/Collections/AgentTypeFactory.php +++ b/database/factories/Collections/AgentTypeFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\AgentType; - class AgentTypeFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = AgentType::class; + protected $model = \App\Models\Collections\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 411828513..dabcf864b 100644 --- a/database/factories/Collections/ArtworkCatalogueFactory.php +++ b/database/factories/Collections/ArtworkCatalogueFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkCatalogue; - class ArtworkCatalogueFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkCatalogue::class; + protected $model = \App\Models\Collections\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 bcaf55757..29c614d9d 100644 --- a/database/factories/Collections/ArtworkDateFactory.php +++ b/database/factories/Collections/ArtworkDateFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkDate; - class ArtworkDateFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkDate::class; + protected $model = \App\Models\Collections\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 0402606b9..9982b574b 100644 --- a/database/factories/Collections/ArtworkDateQualifierFactory.php +++ b/database/factories/Collections/ArtworkDateQualifierFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkDateQualifier; - class ArtworkDateQualifierFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkDateQualifier::class; + protected $model = \App\Models\Collections\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 f11ce8774..17c8ab565 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,18 +9,8 @@ class ArtworkFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Artwork::class; + protected $model = \App\Models\Collections\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 2a129a1da..719d6b75d 100644 --- a/database/factories/Collections/ArtworkPlaceQualifierFactory.php +++ b/database/factories/Collections/ArtworkPlaceQualifierFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkPlaceQualifier; - class ArtworkPlaceQualifierFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkPlaceQualifier::class; + protected $model = \App\Models\Collections\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 499872b5c..001e99a07 100644 --- a/database/factories/Collections/ArtworkTermFactory.php +++ b/database/factories/Collections/ArtworkTermFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkTerm; - class ArtworkTermFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkTerm::class; + protected $model = \App\Models\Collections\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 dc6fafd7b..269c2e9b4 100644 --- a/database/factories/Collections/ArtworkTypeFactory.php +++ b/database/factories/Collections/ArtworkTypeFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\ArtworkType; - class ArtworkTypeFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = ArtworkType::class; + protected $model = \App\Models\Collections\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 92b17199d..386787270 100644 --- a/database/factories/Collections/AssetFactory.php +++ b/database/factories/Collections/AssetFactory.php @@ -2,28 +2,16 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Asset; - class AssetFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Asset::class; + protected $model = \App\Models\Collections\Asset::class; - /** - * Define the model's default state. - * - * @return array - */ 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 1e77cabe3..fd25bfbec 100644 --- a/database/factories/Collections/CategoryFactory.php +++ b/database/factories/Collections/CategoryFactory.php @@ -6,25 +6,15 @@ 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( $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 d6664d8a7..f2e7c1c68 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/ExhibitionFactory.php b/database/factories/Collections/ExhibitionFactory.php index 7965172bd..629aeb48f 100644 --- a/database/factories/Collections/ExhibitionFactory.php +++ b/database/factories/Collections/ExhibitionFactory.php @@ -2,23 +2,12 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Exhibition; use App\Models\Collections\Place; class ExhibitionFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Exhibition::class; + protected $model = \App\Models\Collections\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 e71993586..db609bda7 100644 --- a/database/factories/Collections/GalleryFactory.php +++ b/database/factories/Collections/GalleryFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Gallery; - class GalleryFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Gallery::class; + protected $model = \App\Models\Collections\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 24c139355..5673c4591 100644 --- a/database/factories/Collections/ImageFactory.php +++ b/database/factories/Collections/ImageFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Image; - class ImageFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Image::class; + protected $model = \App\Models\Collections\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 c8841515e..45e4de6c2 100644 --- a/database/factories/Collections/PlaceFactory.php +++ b/database/factories/Collections/PlaceFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Place; - class PlaceFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Place::class; + protected $model = \App\Models\Collections\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 8e1165e1d..a63ee47eb 100644 --- a/database/factories/Collections/SoundFactory.php +++ b/database/factories/Collections/SoundFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Sound; - class SoundFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Sound::class; + protected $model = \App\Models\Collections\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 3f4b8cd4a..e530341f3 100644 --- a/database/factories/Collections/TermFactory.php +++ b/database/factories/Collections/TermFactory.php @@ -2,29 +2,17 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Term; - class TermFactory extends CollectionsFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Term::class; + protected $model = \App\Models\Collections\Term::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( $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/Collections/TextFactory.php b/database/factories/Collections/TextFactory.php index a83778ae5..1ee90bb08 100644 --- a/database/factories/Collections/TextFactory.php +++ b/database/factories/Collections/TextFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Text; - class TextFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Text::class; + protected $model = \App\Models\Collections\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 93cbe8aef..d3b37e56a 100644 --- a/database/factories/Collections/VideoFactory.php +++ b/database/factories/Collections/VideoFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Collections; -use App\Models\Collections\Video; - class VideoFactory extends AssetFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Video::class; + protected $model = \App\Models\Collections\Video::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return array_merge( diff --git a/database/factories/Dsc/DscFactory.php b/database/factories/Dsc/DscFactory.php index e9aea9e05..e62d0d8dd 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/PublicationFactory.php b/database/factories/Dsc/PublicationFactory.php index 204e956c5..a0411b00f 100644 --- a/database/factories/Dsc/PublicationFactory.php +++ b/database/factories/Dsc/PublicationFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Dsc; -use App\Models\Dsc\Publication; - class PublicationFactory extends DscFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Publication::class; + protected $model = \App\Models\Dsc\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 cdaba23bd..2a55bc3f1 100644 --- a/database/factories/Dsc/SectionFactory.php +++ b/database/factories/Dsc/SectionFactory.php @@ -8,24 +8,13 @@ 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( $this->dscIdsAndTitle(), [ - 'web_url' => $this->faker->url, 'accession' => $this->faker->accession, 'revision' => rand(1230768000, 1483228800), // timestamp b/w 2009 and 2017 @@ -35,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 27c234cac..5f3016ad8 100644 --- a/database/factories/Library/MaterialFactory.php +++ b/database/factories/Library/MaterialFactory.php @@ -3,25 +3,14 @@ namespace Database\Factories\Library; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Library\Material; class MaterialFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Material::class; + protected $model = \App\Models\Library\Material::class; - /** - * Define the model's default state. - * - * @return array - */ 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/Library/TermFactory.php b/database/factories/Library/TermFactory.php index 5300b4b63..103138ddb 100644 --- a/database/factories/Library/TermFactory.php +++ b/database/factories/Library/TermFactory.php @@ -3,22 +3,11 @@ namespace Database\Factories\Library; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Library\Term; class TermFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Term::class; + protected $model = \App\Models\Library\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/MembershipFactory.php b/database/factories/Membership/MembershipFactory.php index 04534c0f5..2f8a2e8e3 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)), ]; } @@ -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/factories/Membership/TicketedEventFactory.php b/database/factories/Membership/TicketedEventFactory.php index 24bfe6bb7..8ef65a66d 100644 --- a/database/factories/Membership/TicketedEventFactory.php +++ b/database/factories/Membership/TicketedEventFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Membership; -use App\Models\Membership\TicketedEvent; - class TicketedEventFactory extends MembershipFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = TicketedEvent::class; + protected $model = \App\Models\Membership\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 7cdb58b1e..60f3c388a 100644 --- a/database/factories/Mobile/ArtworkFactory.php +++ b/database/factories/Mobile/ArtworkFactory.php @@ -2,28 +2,16 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Artwork; - class ArtworkFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Artwork::class; + protected $model = \App\Models\Mobile\Artwork::class; - /** - * Define the model's default state. - * - * @return array - */ 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/MobileFactory.php b/database/factories/Mobile/MobileFactory.php index edaaf5fcd..4108c2d26 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/Mobile/SoundFactory.php b/database/factories/Mobile/SoundFactory.php index 8650f522f..da06413aa 100644 --- a/database/factories/Mobile/SoundFactory.php +++ b/database/factories/Mobile/SoundFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Sound; - class SoundFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Sound::class; + protected $model = \App\Models\Mobile\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 209efe851..5aa1d38f9 100644 --- a/database/factories/Mobile/TourFactory.php +++ b/database/factories/Mobile/TourFactory.php @@ -2,23 +2,12 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\Tour; use App\Models\Mobile\Sound; class TourFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Tour::class; + protected $model = \App\Models\Mobile\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 9b2000164..fa87771c4 100644 --- a/database/factories/Mobile/TourStopFactory.php +++ b/database/factories/Mobile/TourStopFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Mobile; -use App\Models\Mobile\TourStop; - class TourStopFactory extends MobileFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = TourStop::class; + protected $model = \App\Models\Mobile\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 d315cb83b..aa7c9bd9d 100644 --- a/database/factories/Shop/ProductFactory.php +++ b/database/factories/Shop/ProductFactory.php @@ -2,22 +2,10 @@ namespace Database\Factories\Shop; -use App\Models\Shop\Product; - class ProductFactory extends ShopFactory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Product::class; + protected $model = \App\Models\Shop\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/Shop/ShopFactory.php b/database/factories/Shop/ShopFactory.php index 8deebdc9a..fcac347de 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 6c68e014f..8ad14c42a 100644 --- a/database/factories/StaticArchive/SiteFactory.php +++ b/database/factories/StaticArchive/SiteFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\StaticArchive; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\StaticArchive\Site; class SiteFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Site::class; + protected $model = \App\Models\StaticArchive\Site::class; - /** - * Define the model's default state. - * - * @return array - */ 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 7bf6112f0..c2a0ff967 100644 --- a/database/factories/Web/ArticleFactory.php +++ b/database/factories/Web/ArticleFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Article; class ArticleFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Article::class; + protected $model = \App\Models\Web\Article::class; - /** - * Define the model's default state. - * - * @return array - */ 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 2151b21b2..fd40b09c0 100644 --- a/database/factories/Web/ArtistFactory.php +++ b/database/factories/Web/ArtistFactory.php @@ -3,28 +3,17 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Artist; class ArtistFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Artist::class; + protected $model = \App\Models\Web\Artist::class; - /** - * Define the model's default state. - * - * @return array - */ 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 66a142157..e49187c62 100644 --- a/database/factories/Web/ClosureFactory.php +++ b/database/factories/Web/ClosureFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Closure; class ClosureFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Closure::class; + protected $model = \App\Models\Web\Closure::class; - /** - * Define the model's default state. - * - * @return array - */ 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 4265b8aa2..b57856781 100644 --- a/database/factories/Web/DigitalCatalogFactory.php +++ b/database/factories/Web/DigitalCatalogFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\DigitalCatalog; class DigitalCatalogFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = DigitalCatalog::class; + protected $model = \App\Models\Web\DigitalCatalog::class; - /** - * Define the model's default state. - * - * @return array - */ 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 f788576da..2ff078979 100644 --- a/database/factories/Web/EducatorResourceFactory.php +++ b/database/factories/Web/EducatorResourceFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\EducatorResource; class EducatorResourceFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = EducatorResource::class; + protected $model = \App\Models\Web\EducatorResource::class; - /** - * Define the model's default state. - * - * @return array - */ 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 9f04009e1..6f35edce5 100644 --- a/database/factories/Web/EventFactory.php +++ b/database/factories/Web/EventFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Event; class EventFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Event::class; + protected $model = \App\Models\Web\Event::class; - /** - * Define the model's default state. - * - * @return array - */ 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 0283d4da3..1267ba97c 100644 --- a/database/factories/Web/EventProgramFactory.php +++ b/database/factories/Web/EventProgramFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\EventProgram; class EventProgramFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = EventProgram::class; + protected $model = \App\Models\Web\EventProgram::class; - /** - * Define the model's default state. - * - * @return array - */ 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 8f7de9989..c8ba21f86 100644 --- a/database/factories/Web/ExhibitionFactory.php +++ b/database/factories/Web/ExhibitionFactory.php @@ -3,29 +3,18 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Exhibition; class ExhibitionFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Exhibition::class; + protected $model = \App\Models\Web\Exhibition::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition() { return [ '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 d7c73ac57..015469dc0 100644 --- a/database/factories/Web/GenericPageFactory.php +++ b/database/factories/Web/GenericPageFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\GenericPage; class GenericPageFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = GenericPage::class; + protected $model = \App\Models\Web\GenericPage::class; - /** - * Define the model's default state. - * - * @return array - */ 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 2bf35bcf9..a1210b9ea 100644 --- a/database/factories/Web/HighlightFactory.php +++ b/database/factories/Web/HighlightFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\Highlight; class HighlightFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = Highlight::class; + protected $model = \App\Models\Web\Highlight::class; - /** - * Define the model's default state. - * - * @return array - */ 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 91330c2ed..3d359cec9 100644 --- a/database/factories/Web/PressReleaseFactory.php +++ b/database/factories/Web/PressReleaseFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\PressRelease; class PressReleaseFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = PressRelease::class; + protected $model = \App\Models\Web\PressRelease::class; - /** - * Define the model's default state. - * - * @return array - */ 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 70bf83d86..ebdc29cce 100644 --- a/database/factories/Web/PrintedCatalogFactory.php +++ b/database/factories/Web/PrintedCatalogFactory.php @@ -3,26 +3,15 @@ namespace Database\Factories\Web; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Web\PrintedCatalog; class PrintedCatalogFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string|null - */ - protected $model = PrintedCatalog::class; + protected $model = \App\Models\Web\PrintedCatalog::class; - /** - * Define the model's default state. - * - * @return array - */ 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/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 3f8e62d17..9643563cf 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 700117dc3..807176851 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 23737c1e3..bdc077b36 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 03115b418..b2a7916b8 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 36c1bccf2..f9618fbbe 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 df2bcf413..3862364ca 100644 --- a/tests/Helpers/Factory.php +++ b/tests/Helpers/Factory.php @@ -2,8 +2,6 @@ namespace Tests\Helpers; -use Illuminate\Support\Str; - trait Factory {