diff --git a/app/Console/Commands/FetchMetaData.php b/app/Console/Commands/FetchMetaData.php index 5bbffba..3a59eb1 100644 --- a/app/Console/Commands/FetchMetaData.php +++ b/app/Console/Commands/FetchMetaData.php @@ -72,9 +72,9 @@ public function handle(): void //ProcessKlingonName::dispatch($name); } - if (is_null($name->unisex)) { - ProcessMixte::dispatch($name); - } + // if (is_null($name->unisex)) { + // ProcessMixte::dispatch($name); + // } } } } diff --git a/app/Helpers/StringHelper.php b/app/Helpers/StringHelper.php index 41f7ed2..3245922 100644 --- a/app/Helpers/StringHelper.php +++ b/app/Helpers/StringHelper.php @@ -2,6 +2,8 @@ namespace App\Helpers; +use Illuminate\Support\Str; + class StringHelper { public static function sanitizeNameForURL(string $name): string @@ -18,7 +20,7 @@ public static function sanitizeNameForURL(string $name): string public static function getProperName(string $name): string { - $formattedName = ucwords(strtolower($name)); + $formattedName = Str::ucfirst(Str::lower($name)); $separator = [' ', '-', '+', "'"]; foreach ($separator as $s) { diff --git a/app/Http/Controllers/NameController.php b/app/Http/Controllers/NameController.php index aeaa028..82caf1f 100644 --- a/app/Http/Controllers/NameController.php +++ b/app/Http/Controllers/NameController.php @@ -63,10 +63,20 @@ public function show(Request $request): View return NameViewModel::relatedNames($requestedName); }); + $popularity = Cache::remember('popularity-' . $requestedName->name, 604800, function () use ($requestedName) { + return NameViewModel::popularity($requestedName); + }); + + $numerology = Cache::remember('numerology-' . $requestedName->name, 604800, function () use ($requestedName) { + return NameViewModel::numerology($requestedName); + }); + return view('names.show', [ 'name' => $name, + 'popularity' => $popularity, 'relatedNames' => $relatedNames, 'jsonLdSchema' => NameViewModel::jsonLdSchema($requestedName), + 'numerology' => $numerology, ]); } diff --git a/app/Http/ViewModels/Names/NameViewModel.php b/app/Http/ViewModels/Names/NameViewModel.php index 435f0f8..c6bbca3 100644 --- a/app/Http/ViewModels/Names/NameViewModel.php +++ b/app/Http/ViewModels/Names/NameViewModel.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Str; +use Illuminate\Support\Number; class NameViewModel { @@ -33,6 +34,36 @@ public static function details(Name $name): array ]; } + public static function popularity(Name $name): array + { + $decades = range(1900, Carbon::now()->year, 10); + + $decadesCollection = collect(); + foreach ($decades as $decade) { + $popularity = $name->nameStatistics() + ->where('year', '>=', $decade) + ->where('year', '<', $decade + 9) + ->sum('count'); + + $decadesCollection->push([ + 'decade' => $decade . 's', + 'popularity' => $popularity, + 'percentage' => 0, + ]); + } + + // now we need to add the percentage of popularity for each decade + $total = $decadesCollection->sum('popularity'); + $decadesCollection = $decadesCollection->map(function ($decade) use ($total) { + $decade['percentage'] = Number::format(round($decade['popularity'] / $total * 100), locale: 'fr'); + return $decade; + }); + + return [ + 'decades' => $decadesCollection, + ]; + } + public static function jsonLdSchema(Name $name): array { return [ @@ -64,4 +95,45 @@ public static function relatedNames(Name $name): Collection ]), ]); } + + public static function numerology(Name $name): int + { + // for each letter in the name, we need to get the corresponding number + // letter A is 1, letter B is 2, etc... until letter I is 9 + // then we start over, letter J is 1, letter K is 2, etc... until letter R is 9 + // then we start over, letter S is 1, letter T is 2, etc... until letter Z is 8 + // then we add all the numbers together and we get the number for the name + // if the number is greater than 9, we add the digits together until we get a number between 1 and 9 + // if the number is 11, 22 or 33, we keep it as is + + $letters = str_split($name->name); + $numbers = []; + foreach ($letters as $letter) { + if ($letter === '_' || $letter === ' ' || $letter === '-' || $letter === "'") { + continue; + } + + $number = match ($letter) { + 'A', 'J', 'S' => 1, + 'B', 'K', 'T' => 2, + 'C', 'L', 'U' => 3, + 'D', 'M', 'V' => 4, + 'E', 'N', 'W' => 5, + 'F', 'O', 'X' => 6, + 'G', 'P', 'Y' => 7, + 'H', 'Q', 'Z' => 8, + 'I', 'R' => 9, + default => 0, + }; + + $numbers[] = $number; + } + + $number = array_sum($numbers); + while ($number > 9) { + $number = array_sum(str_split($number)); + } + + return $number; + } } diff --git a/bun.lockb b/bun.lockb index 9253624..2312026 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/composer.lock b/composer.lock index f4ef99b..e5630c4 100644 --- a/composer.lock +++ b/composer.lock @@ -86,16 +86,16 @@ }, { "name": "blade-ui-kit/blade-heroicons", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/blade-ui-kit/blade-heroicons.git", - "reference": "f756c807b0d04afd2caf7079bac26492da9cc6d4" + "reference": "8d5abd00bd274928b50307882d635fcc013866c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/blade-ui-kit/blade-heroicons/zipball/f756c807b0d04afd2caf7079bac26492da9cc6d4", - "reference": "f756c807b0d04afd2caf7079bac26492da9cc6d4", + "url": "https://api.github.com/repos/blade-ui-kit/blade-heroicons/zipball/8d5abd00bd274928b50307882d635fcc013866c3", + "reference": "8d5abd00bd274928b50307882d635fcc013866c3", "shasum": "" }, "require": { @@ -139,19 +139,19 @@ ], "support": { "issues": "https://github.com/blade-ui-kit/blade-heroicons/issues", - "source": "https://github.com/blade-ui-kit/blade-heroicons/tree/2.1.0" + "source": "https://github.com/blade-ui-kit/blade-heroicons/tree/2.2.0" }, "funding": [ { - "url": "https://github.com/caneco", + "url": "https://github.com/sponsors/driesvints", "type": "github" }, { - "url": "https://github.com/driesvints", - "type": "github" + "url": "https://www.paypal.com/paypalme/driesvints", + "type": "paypal" } ], - "time": "2023-01-11T08:38:22+00:00" + "time": "2023-12-18T17:41:29+00:00" }, { "name": "blade-ui-kit/blade-icons", @@ -1422,16 +1422,16 @@ }, { "name": "laravel/framework", - "version": "v10.35.0", + "version": "v10.37.3", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "91ec2d92d2f6007e9084fe06438b99c91845da69" + "reference": "996375dd61f8c6e4ac262b57ed485655d71fcbdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/91ec2d92d2f6007e9084fe06438b99c91845da69", - "reference": "91ec2d92d2f6007e9084fe06438b99c91845da69", + "url": "https://api.github.com/repos/laravel/framework/zipball/996375dd61f8c6e4ac262b57ed485655d71fcbdc", + "reference": "996375dd61f8c6e4ac262b57ed485655d71fcbdc", "shasum": "" }, "require": { @@ -1620,7 +1620,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-05T14:50:33+00:00" + "time": "2023-12-13T20:10:58+00:00" }, { "name": "laravel/prompts", @@ -7874,16 +7874,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "0.5.1", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623" + "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/b58e5a3933e541dc286cc91fc4f3898bbc6f1623", - "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/85193c0b0cb5c47894b5eaec906e946f054e7077", + "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077", "shasum": "" }, "require": { @@ -7891,13 +7891,13 @@ }, "require-dev": { "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", "phpstan/extension-installer": "^1.2.0", "phpstan/phpstan": "^1.9.2", "phpstan/phpstan-deprecation-rules": "^1.0.0", "phpstan/phpstan-phpunit": "^1.2.2", "phpstan/phpstan-strict-rules": "^1.4.4", - "phpunit/phpunit": "^9.5.26 || ^8.5.31", - "theofidry/php-cs-fixer-config": "^1.0", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", "webmozarts/strict-phpunit": "^7.5" }, "type": "library", @@ -7923,7 +7923,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/0.5.1" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.0.0" }, "funding": [ { @@ -7931,7 +7931,7 @@ "type": "github" } ], - "time": "2022-12-24T12:35:10+00:00" + "time": "2023-09-17T21:38:23+00:00" }, { "name": "filp/whoops", @@ -8057,16 +8057,16 @@ }, { "name": "laravel/breeze", - "version": "v1.26.2", + "version": "v1.26.3", "source": { "type": "git", "url": "https://github.com/laravel/breeze.git", - "reference": "60f339c38098bc5adbf8614bf5d89b77647a06c5" + "reference": "a09d3664b5154377e2b0ebdf54fcae3d331e176d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/breeze/zipball/60f339c38098bc5adbf8614bf5d89b77647a06c5", - "reference": "60f339c38098bc5adbf8614bf5d89b77647a06c5", + "url": "https://api.github.com/repos/laravel/breeze/zipball/a09d3664b5154377e2b0ebdf54fcae3d331e176d", + "reference": "a09d3664b5154377e2b0ebdf54fcae3d331e176d", "shasum": "" }, "require": { @@ -8115,7 +8115,7 @@ "issues": "https://github.com/laravel/breeze/issues", "source": "https://github.com/laravel/breeze" }, - "time": "2023-11-24T14:41:28+00:00" + "time": "2023-12-06T18:27:17+00:00" }, { "name": "laravel/dusk", @@ -8783,16 +8783,16 @@ }, { "name": "orchestra/canvas", - "version": "v8.11.4", + "version": "v8.11.5", "source": { "type": "git", "url": "https://github.com/orchestral/canvas.git", - "reference": "466ed3d7c1755e49be1c8e5557b434381b8ab6d1" + "reference": "5bc4c6c4cb17c558db5b22ad85c2701486b8e81d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/canvas/zipball/466ed3d7c1755e49be1c8e5557b434381b8ab6d1", - "reference": "466ed3d7c1755e49be1c8e5557b434381b8ab6d1", + "url": "https://api.github.com/repos/orchestral/canvas/zipball/5bc4c6c4cb17c558db5b22ad85c2701486b8e81d", + "reference": "5bc4c6c4cb17c558db5b22ad85c2701486b8e81d", "shasum": "" }, "require": { @@ -8851,9 +8851,9 @@ "description": "Code Generators for Laravel Applications and Packages", "support": { "issues": "https://github.com/orchestral/canvas/issues", - "source": "https://github.com/orchestral/canvas/tree/v8.11.4" + "source": "https://github.com/orchestral/canvas/tree/v8.11.5" }, - "time": "2023-11-27T04:47:24+00:00" + "time": "2023-12-05T22:49:56+00:00" }, { "name": "orchestra/canvas-core", @@ -9572,16 +9572,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.4", + "version": "1.24.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", "shasum": "" }, "require": { @@ -9613,22 +9613,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" }, - "time": "2023-11-26T18:29:22+00:00" + "time": "2023-12-16T09:33:33+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.49", + "version": "1.10.50", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9367ba4c4f6ad53e9efb594d74a8941563caccf6" + "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9367ba4c4f6ad53e9efb594d74a8941563caccf6", - "reference": "9367ba4c4f6ad53e9efb594d74a8941563caccf6", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", + "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", "shasum": "" }, "require": { @@ -9677,7 +9677,7 @@ "type": "tidelift" } ], - "time": "2023-12-12T10:05:12+00:00" + "time": "2023-12-13T10:59:42+00:00" }, { "name": "phpunit/php-code-coverage", @@ -10002,16 +10002,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.2", + "version": "10.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe" + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5aedff46afba98dddecaa12349ec044d9103d4fe", - "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6fce887c71076a73f32fd3e0774a6833fc5c7f19", + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19", "shasum": "" }, "require": { @@ -10083,7 +10083,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.3" }, "funding": [ { @@ -10099,7 +10099,7 @@ "type": "tidelift" } ], - "time": "2023-12-05T14:54:33+00:00" + "time": "2023-12-13T07:25:23+00:00" }, { "name": "pimple/pimple", @@ -11471,16 +11471,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "2.3.1", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "bf21cd15aa47fa4ec5d73bbc932005c70261efc8" + "reference": "4800661a195e15783477d99f7f8f669a49793996" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/bf21cd15aa47fa4ec5d73bbc932005c70261efc8", - "reference": "bf21cd15aa47fa4ec5d73bbc932005c70261efc8", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/4800661a195e15783477d99f7f8f669a49793996", + "reference": "4800661a195e15783477d99f7f8f669a49793996", "shasum": "" }, "require": { @@ -11559,7 +11559,7 @@ "type": "github" } ], - "time": "2023-10-09T12:55:26+00:00" + "time": "2023-12-15T13:44:49+00:00" }, { "name": "spatie/laravel-ray", @@ -12104,16 +12104,16 @@ }, { "name": "tightenco/duster", - "version": "v2.6.0", + "version": "v2.7.1", "source": { "type": "git", "url": "https://github.com/tighten/duster.git", - "reference": "eb0e339c30abc990738f7881173f733e6520e424" + "reference": "3e2072117576e4bf6f8da8539930a1b1cc7853fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tighten/duster/zipball/eb0e339c30abc990738f7881173f733e6520e424", - "reference": "eb0e339c30abc990738f7881173f733e6520e424", + "url": "https://api.github.com/repos/tighten/duster/zipball/3e2072117576e4bf6f8da8539930a1b1cc7853fb", + "reference": "3e2072117576e4bf6f8da8539930a1b1cc7853fb", "shasum": "" }, "require": { @@ -12170,20 +12170,20 @@ "issues": "https://github.com/tighten/duster/issues", "source": "https://github.com/tighten/duster" }, - "time": "2023-12-01T18:43:59+00:00" + "time": "2023-12-15T22:29:57+00:00" }, { "name": "vimeo/psalm", - "version": "5.17.0", + "version": "5.18.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "c620f6e80d0abfca532b00bda366062aaedf6e5d" + "reference": "b113f3ed0259fd6e212d87c3df80eec95a6abf19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/c620f6e80d0abfca532b00bda366062aaedf6e5d", - "reference": "c620f6e80d0abfca532b00bda366062aaedf6e5d", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/b113f3ed0259fd6e212d87c3df80eec95a6abf19", + "reference": "b113f3ed0259fd6e212d87c3df80eec95a6abf19", "shasum": "" }, "require": { @@ -12202,7 +12202,7 @@ "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.1", "felixfbecker/language-server-protocol": "^1.5.2", - "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", + "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^4.16", "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", @@ -12280,7 +12280,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2023-12-03T20:21:41+00:00" + "time": "2023-12-16T09:37:35+00:00" }, { "name": "zbateson/mail-mime-parser", diff --git a/package.json b/package.json index 544012e..7d2f46b 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "vite": "^4.0.0" }, "dependencies": { - "@tailwindcss/typography": "^0.5.10" + "@tailwindcss/typography": "^0.5.10", + "charts.css": "^1.1.0" } } diff --git a/resources/css/app.css b/resources/css/app.css index ef161ce..21b94e1 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -2,6 +2,7 @@ @tailwind components; @tailwind utilities; + .name-show-grid { grid-template-columns: 1fr 240px; } @@ -9,3 +10,13 @@ .name-index-grid { grid-template-columns: 240px 1fr; } + +@media (max-width: 480px) { + .name-show-grid { + grid-template-columns: 1fr; + } + + .name-index-grid { + grid-template-columns: 1fr; + } +} diff --git a/resources/js/app.js b/resources/js/app.js index 75c1524..6f35946 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -2,6 +2,7 @@ import './bootstrap'; import Alpine from 'alpinejs'; import htmx from 'htmx.org'; +import 'charts.css'; window.Alpine = Alpine; window.htmx = htmx; diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index 4242b9b..957a5ee 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -4,9 +4,9 @@ @include('layouts.unlogged-navigation') -
+
+ {{ $popularityItem['decade'] }} + | ++ {{ $popularityItem['popularity'] }} + | +
---|