diff --git a/app/Http/Controllers/FemaleNameController.php b/app/Http/Controllers/FemaleNameController.php index 0e370d1..527cfc6 100644 --- a/app/Http/Controllers/FemaleNameController.php +++ b/app/Http/Controllers/FemaleNameController.php @@ -3,10 +3,7 @@ namespace App\Http\Controllers; use App\Helpers\StringHelper; -use App\Http\ViewModels\Names\AllNamesViewModel; use App\Http\ViewModels\Names\FemaleNamesViewModel; -use App\Http\ViewModels\Names\MaleNamesViewModel; -use App\Http\ViewModels\Names\NameViewModel; use App\Models\Name; use Illuminate\Http\Request; use Illuminate\Pagination\Paginator; @@ -29,7 +26,7 @@ public function index(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('all-names-female-page-'.$requestedPage, 604800, function () { + $namesPagination = Cache::remember('all-names-female-page-' . $requestedPage, 604800, function () { return Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'female') ->orderBy('name', 'asc') @@ -67,7 +64,7 @@ public function letter(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('female-letter-'.$requestedLetter.'-page-' . $requestedPage, 604800, function () use ($requestedLetter) { + $namesPagination = Cache::remember('female-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, function () use ($requestedLetter) { return Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'female') ->where('name', 'like', $requestedLetter . '%') diff --git a/app/Http/Controllers/MaleNameController.php b/app/Http/Controllers/MaleNameController.php index 444346d..bb001bc 100644 --- a/app/Http/Controllers/MaleNameController.php +++ b/app/Http/Controllers/MaleNameController.php @@ -3,9 +3,7 @@ namespace App\Http\Controllers; use App\Helpers\StringHelper; -use App\Http\ViewModels\Names\AllNamesViewModel; use App\Http\ViewModels\Names\MaleNamesViewModel; -use App\Http\ViewModels\Names\NameViewModel; use App\Models\Name; use Illuminate\Http\Request; use Illuminate\Pagination\Paginator; @@ -28,7 +26,7 @@ public function index(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('all-names-male-page-'.$requestedPage, 604800, function () { + $namesPagination = Cache::remember('all-names-male-page-' . $requestedPage, 604800, function () { return Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'male') ->orderBy('name', 'asc') @@ -66,7 +64,7 @@ public function letter(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('male-letter-'.$requestedLetter.'-page-' . $requestedPage, 604800, function () use ($requestedLetter) { + $namesPagination = Cache::remember('male-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, function () use ($requestedLetter) { return Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'male') ->where('name', 'like', $requestedLetter . '%') diff --git a/app/Http/Controllers/NameController.php b/app/Http/Controllers/NameController.php index 689160b..aeaa028 100644 --- a/app/Http/Controllers/NameController.php +++ b/app/Http/Controllers/NameController.php @@ -27,7 +27,7 @@ public function index(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('all-names-page-'.$requestedPage, 604800, function () { + $namesPagination = Cache::remember('all-names-page-' . $requestedPage, 604800, function () { return Name::where('name', '!=', '_PRENOMS_RARES') ->orderBy('name', 'asc') ->paginate(40); @@ -51,6 +51,25 @@ public function index(Request $request): View ]); } + public function show(Request $request): View + { + $requestedName = $request->attributes->get('name'); + + $name = Cache::remember('name-' . $requestedName->name, 604800, function () use ($requestedName) { + return NameViewModel::details($requestedName); + }); + + $relatedNames = Cache::remember('related-names-' . $requestedName->name, 60, function () use ($requestedName) { + return NameViewModel::relatedNames($requestedName); + }); + + return view('names.show', [ + 'name' => $name, + 'relatedNames' => $relatedNames, + 'jsonLdSchema' => NameViewModel::jsonLdSchema($requestedName), + ]); + } + public function letter(Request $request): View { $requestedLetter = $request->attributes->get('letter'); @@ -64,7 +83,7 @@ public function letter(Request $request): View return $requestedPage; }); - $namesPagination = Cache::remember('letter-'.$requestedLetter.'-page-' . $requestedPage, 604800, function () use ($requestedLetter) { + $namesPagination = Cache::remember('letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, function () use ($requestedLetter) { return Name::where('name', '!=', '_PRENOMS_RARES') ->where('name', 'like', $requestedLetter . '%') ->orderBy('name', 'asc') @@ -89,23 +108,4 @@ public function letter(Request $request): View 'activeLetter' => Str::ucfirst($requestedLetter), ]); } - - public function show(Request $request): View - { - $requestedName = $request->attributes->get('name'); - - $name = Cache::remember('name-' . $requestedName->name, 604800, function () use ($requestedName) { - return NameViewModel::details($requestedName); - }); - - $relatedNames = Cache::remember('related-names-' . $requestedName->name, 60, function () use ($requestedName) { - return NameViewModel::relatedNames($requestedName); - }); - - return view('names.show', [ - 'name' => $name, - 'relatedNames' => $relatedNames, - 'jsonLdSchema' => NameViewModel::jsonLdSchema($requestedName), - ]); - } } diff --git a/app/Http/Middleware/CheckLetter.php b/app/Http/Middleware/CheckLetter.php index b6fb333..ebca0ad 100644 --- a/app/Http/Middleware/CheckLetter.php +++ b/app/Http/Middleware/CheckLetter.php @@ -2,11 +2,8 @@ namespace App\Http\Middleware; -use App\Models\Name; use Closure; -use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Symfony\Component\HttpFoundation\Response; @@ -26,7 +23,7 @@ public function handle(Request $request, Closure $next): Response return redirect()->route('home.index'); } - if (!preg_match('/^[A-Za-z]+$/', $requestedLetter)) { + if (! preg_match('/^[A-Za-z]+$/', $requestedLetter)) { return redirect()->route('home.index'); } diff --git a/app/Http/ViewModels/Names/AllNamesViewModel.php b/app/Http/ViewModels/Names/AllNamesViewModel.php index 2266034..543c685 100644 --- a/app/Http/ViewModels/Names/AllNamesViewModel.php +++ b/app/Http/ViewModels/Names/AllNamesViewModel.php @@ -2,12 +2,10 @@ namespace App\Http\ViewModels\Names; -use App\Helpers\StringHelper; use App\Models\Name; -use Carbon\Carbon; use Illuminate\Support\Collection; -use Illuminate\Support\Str; use Illuminate\Support\Number; +use Illuminate\Support\Str; class AllNamesViewModel { diff --git a/app/Http/ViewModels/Names/FemaleNamesViewModel.php b/app/Http/ViewModels/Names/FemaleNamesViewModel.php index 2347d2a..e1e53cd 100644 --- a/app/Http/ViewModels/Names/FemaleNamesViewModel.php +++ b/app/Http/ViewModels/Names/FemaleNamesViewModel.php @@ -2,12 +2,10 @@ namespace App\Http\ViewModels\Names; -use App\Helpers\StringHelper; use App\Models\Name; -use Carbon\Carbon; use Illuminate\Support\Collection; -use Illuminate\Support\Str; use Illuminate\Support\Number; +use Illuminate\Support\Str; class FemaleNamesViewModel { @@ -33,7 +31,7 @@ public static function index(): Collection 'letter' => $letter, 'count' => Number::format($total, locale: 'fr'), 'url' => route('name.fille.letter', [ - 'letter' => Str::lcfirst($letter) + 'letter' => Str::lcfirst($letter), ]), ]); } diff --git a/app/Http/ViewModels/Names/MaleNamesViewModel.php b/app/Http/ViewModels/Names/MaleNamesViewModel.php index 2b60ec0..9d5ce54 100644 --- a/app/Http/ViewModels/Names/MaleNamesViewModel.php +++ b/app/Http/ViewModels/Names/MaleNamesViewModel.php @@ -2,12 +2,10 @@ namespace App\Http\ViewModels\Names; -use App\Helpers\StringHelper; use App\Models\Name; -use Carbon\Carbon; use Illuminate\Support\Collection; -use Illuminate\Support\Str; use Illuminate\Support\Number; +use Illuminate\Support\Str; class MaleNamesViewModel { @@ -33,7 +31,7 @@ public static function index(): Collection 'letter' => $letter, 'count' => Number::format($total, locale: 'fr'), 'url' => route('name.garcon.letter', [ - 'letter' => Str::lcfirst($letter) + 'letter' => Str::lcfirst($letter), ]), ]); } diff --git a/resources/js/app.js b/resources/js/app.js index b81e1ed..75c1524 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,11 +1,9 @@ import './bootstrap'; import Alpine from 'alpinejs'; -//import 'htmx.org/dist/ext/preload.js'; import htmx from 'htmx.org'; window.Alpine = Alpine; -//window.htmx = htmx.org; window.htmx = htmx; Alpine.start(); diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index f0cc3e5..4242b9b 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -15,7 +15,7 @@

Parcourez le site de fiches de prénoms le plus complet. Créez des listes et faites voter vos proches. Un site qui vous respecte, sans pub, sans tracking et open source.

- Parcourir tous les prénoms + Parcourir tous les prénoms

@@ -38,7 +38,7 @@
{{ $nameSpotlight['origins'] }}

- Lire plus + + Lire plus +

@@ -71,7 +71,7 @@ @foreach ($twentyMostPopularNames['male_names'] as $name)
  • {!! $name['avatar'] !!}
    - {{ $name['name'] }} + {{ $name['name'] }}
  • @endforeach @@ -84,7 +84,7 @@ @foreach ($twentyMostPopularNames['female_names'] as $name)
  • {!! $name['avatar'] !!}
    - {{ $name['name'] }} + {{ $name['name'] }}
  • @endforeach @@ -97,7 +97,7 @@ @foreach ($twentyMostPopularNames['male_names'] as $name)
  • {!! $name['avatar'] !!}
    - {{ $name['name'] }} + {{ $name['name'] }}
  • @endforeach @@ -110,7 +110,7 @@ @foreach ($twentyMostPopularNames['random_names'] as $name)
  • {!! $name['avatar'] !!}
    - {{ $name['name'] }} + {{ $name['name'] }}
  • @endforeach diff --git a/resources/views/layouts/unlogged-navigation.blade.php b/resources/views/layouts/unlogged-navigation.blade.php index d7f51ac..353eab2 100644 --- a/resources/views/layouts/unlogged-navigation.blade.php +++ b/resources/views/layouts/unlogged-navigation.blade.php @@ -15,10 +15,10 @@