diff --git a/app/Helpers/StringHelper.php b/app/Helpers/StringHelper.php index 10a3a30..2d77f6e 100644 --- a/app/Helpers/StringHelper.php +++ b/app/Helpers/StringHelper.php @@ -40,4 +40,11 @@ public static function formatNameFromDB(string $name): string return $formattedName; } + + public static function shareLink(string $uuid): string + { + return route('share.show', [ + 'uuid' => $uuid, + ]); + } } diff --git a/app/Http/Controllers/NameController.php b/app/Http/Controllers/NameController.php index 05baf06..299be2d 100644 --- a/app/Http/Controllers/NameController.php +++ b/app/Http/Controllers/NameController.php @@ -77,12 +77,15 @@ public function show(Request $request): View if (! auth()->check()) { $favoritedNamesForLoggedUser = collect(); $lists = []; + $note = ''; } else { $favoritedNamesForLoggedUser = Cache::remember('user-favorites-' . auth()->id(), 604800, function () { return UserViewModel::favorites(); }); $lists = ListViewModel::lists($requestedName); + + $note = $requestedName->getNoteForUser(); } return view('names.show', [ @@ -93,6 +96,15 @@ public function show(Request $request): View 'numerology' => $numerology, 'favorites' => $favoritedNamesForLoggedUser, 'lists' => $lists, + 'note' => $note, + 'url' => [ + 'edit' => route('user.name.edit', [ + 'id' => $requestedName->id, + ]), + 'delete' => route('user.name.destroy', [ + 'id' => $requestedName->id, + ]), + ], ]); } diff --git a/app/Http/Controllers/NameFavoriteController.php b/app/Http/Controllers/NameFavoriteController.php index cffdf13..b0a7fea 100644 --- a/app/Http/Controllers/NameFavoriteController.php +++ b/app/Http/Controllers/NameFavoriteController.php @@ -19,6 +19,7 @@ public function update(Request $request): View ))->execute(); Cache::forget('user-favorites-' . auth()->id()); + Cache::forget('user-favorites-details-' . auth()->id()); return view('components.favorite', [ 'name' => NameViewModel::details($name), diff --git a/app/Http/Controllers/ShareController.php b/app/Http/Controllers/ShareController.php new file mode 100644 index 0000000..c84e51d --- /dev/null +++ b/app/Http/Controllers/ShareController.php @@ -0,0 +1,12 @@ +attributes->get('name'); + + return view('components.note-show', [ + 'note' => $name->getNoteForUser(), + 'url' => route('user.name.edit', [ + 'id' => $name->id, + ]), + 'deleteUrl' => route('user.name.destroy', [ + 'id' => $name->id, + ]), + ]); + } + + public function edit(Request $request): View + { + $name = $request->attributes->get('name'); + + return view('names.partials.edit-note', [ + 'note' => $name->getNoteForUser(), + 'url' => [ + 'show' => route('user.name.show', [ + 'id' => $name->id, + ]), + 'update' => route('user.name.update', [ + 'id' => $name->id, + 'name' => StringHelper::sanitizeNameForURL($name->name), + ]), + ], + ]); + } + + public function update(Request $request): View + { + $name = $request->attributes->get('name'); + + (new AddNoteToName( + nameId: $name->id, + userId: auth()->id(), + noteText: $request->input('note'), + ))->execute(); + + Cache::forget('user-favorites-' . auth()->id()); + Cache::forget('user-favorites-details-' . auth()->id()); + + return view('components.note-show', [ + 'note' => $name->getNoteForUser(), + 'url' => route('user.name.edit', [ + 'id' => $name->id, + ]), + 'deleteUrl' => route('user.name.destroy', [ + 'id' => $name->id, + ]), + ]); + } + + public function destroy(Request $request): View + { + $name = $request->attributes->get('name'); + + (new DestroyNote( + userId: auth()->id(), + nameId: $name->id, + ))->execute(); + + Cache::forget('user-favorites-' . auth()->id()); + Cache::forget('user-favorites-details-' . auth()->id()); + + return view('components.note-show', [ + 'note' => $name->getNoteForUser(), + 'url' => route('user.name.edit', [ + 'id' => $name->id, + ]), + 'deleteUrl' => route('user.name.destroy', [ + 'id' => $name->id, + ]), + ]); + } +} diff --git a/app/Http/ViewModels/Names/NameViewModel.php b/app/Http/ViewModels/Names/NameViewModel.php index 2308ceb..210c81f 100644 --- a/app/Http/ViewModels/Names/NameViewModel.php +++ b/app/Http/ViewModels/Names/NameViewModel.php @@ -56,6 +56,9 @@ public static function details(Name $name): array 'favorite' => route('favorite.name.update', [ 'id' => $name->id, ]), + 'note_edit' => route('user.name.update', [ + 'id' => $name->id, + ]), ], ]; } diff --git a/app/Http/ViewModels/Search/SearchViewModel.php b/app/Http/ViewModels/Search/SearchViewModel.php index e28d14e..0d35512 100644 --- a/app/Http/ViewModels/Search/SearchViewModel.php +++ b/app/Http/ViewModels/Search/SearchViewModel.php @@ -16,6 +16,7 @@ public static function names(?string $term = null, int $limit = 20): array ->map(fn (Name $name) => [ 'id' => $name->id, 'name' => StringHelper::formatNameFromDB($name->name), + 'gender' => $name->gender == 'male' ? 'masculin' : 'feminin', 'url' => [ 'show' => route('name.show', [ 'id' => $name->id, diff --git a/app/Http/ViewModels/User/ListViewModel.php b/app/Http/ViewModels/User/ListViewModel.php index cf2b979..bc3bfc0 100644 --- a/app/Http/ViewModels/User/ListViewModel.php +++ b/app/Http/ViewModels/User/ListViewModel.php @@ -60,6 +60,7 @@ public static function show(NameList $list): array 'name' => $list->name, 'description' => $list->description, 'names' => $names, + 'uuid' => StringHelper::shareLink($list->uuid), 'url' => [ 'show' => route('list.show', [ 'liste' => $list->id, diff --git a/app/Http/ViewModels/User/UserViewModel.php b/app/Http/ViewModels/User/UserViewModel.php index 662b196..6f6307f 100644 --- a/app/Http/ViewModels/User/UserViewModel.php +++ b/app/Http/ViewModels/User/UserViewModel.php @@ -35,6 +35,7 @@ public static function index(): array 'id' => $name->id, 'name' => StringHelper::formatNameFromDB($name->name), 'total' => Number::format($name->total, locale: 'fr'), + 'note' => $name->getNoteForUser(), 'url' => [ 'show' => route('name.show', [ 'id' => $name->id, diff --git a/app/Models/Name.php b/app/Models/Name.php index e92e345..6193ee8 100644 --- a/app/Models/Name.php +++ b/app/Models/Name.php @@ -77,4 +77,21 @@ public function toSitemapTag(): Url|string|array ->setChangeFrequency(Url::CHANGE_FREQUENCY_MONTHLY) ->setPriority(0.1); } + + public function getNoteForUser(): ?string + { + if (! auth()->check()) { + return null; + } + + $note = Note::where('name_id', $this->id) + ->where('user_id', auth()->id()) + ->first(); + + if (! $note) { + return null; + } + + return $note->content; + } } diff --git a/app/Models/NameList.php b/app/Models/NameList.php index 7a31c99..f621954 100644 --- a/app/Models/NameList.php +++ b/app/Models/NameList.php @@ -19,6 +19,7 @@ class NameList extends Model protected $fillable = [ 'user_id', + 'uuid', 'name', 'description', 'is_public', diff --git a/app/Models/Note.php b/app/Models/Note.php new file mode 100644 index 0000000..0c4e23a --- /dev/null +++ b/app/Models/Note.php @@ -0,0 +1,30 @@ +belongsTo(User::class); + } + + public function name(): BelongsTo + { + return $this->belongsTo(Name::class); + } +} diff --git a/app/Services/AddNoteToName.php b/app/Services/AddNoteToName.php new file mode 100644 index 0000000..3c7c9f9 --- /dev/null +++ b/app/Services/AddNoteToName.php @@ -0,0 +1,34 @@ +create(); + + return $this->note; + } + + private function create(): void + { + $this->note = Note::updateOrCreate([ + 'name_id' => $this->nameId, + 'user_id' => $this->userId, + ], [ + 'content' => $this->noteText, + ]); + } +} diff --git a/app/Services/CreateAccount.php b/app/Services/CreateAccount.php index 5e20c6b..efb51af 100644 --- a/app/Services/CreateAccount.php +++ b/app/Services/CreateAccount.php @@ -5,6 +5,7 @@ use App\Models\NameList; use App\Models\User; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Str; /** * Create an account for the user. @@ -55,6 +56,7 @@ private function createDefaultList(): void 'is_public' => false, 'can_be_modified' => true, 'is_list_of_favorites' => false, + 'uuid' => Str::uuid(), ]); } } diff --git a/app/Services/CreateList.php b/app/Services/CreateList.php index 7e8e15d..3baa266 100644 --- a/app/Services/CreateList.php +++ b/app/Services/CreateList.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Models\NameList; +use Illuminate\Support\Str; class CreateList extends BaseService { @@ -27,6 +28,7 @@ private function createList(): void { $this->nameList = NameList::create([ 'user_id' => auth()->id(), + 'uuid' => Str::uuid(), 'name' => $this->name, 'description' => $this->description, 'is_public' => $this->isPublic, diff --git a/app/Services/DestroyNote.php b/app/Services/DestroyNote.php new file mode 100644 index 0000000..d65faa4 --- /dev/null +++ b/app/Services/DestroyNote.php @@ -0,0 +1,31 @@ +check(); + } + + private function check(): void + { + $this->note = Note::where([ + 'name_id' => $this->nameId, + 'user_id' => $this->userId, + ])->firstOrFail(); + + $this->note->delete(); + } +} diff --git a/bun.lockb b/bun.lockb index 707fee9..edc0dbb 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/composer.lock b/composer.lock index 55083fc..68cdbe0 100644 --- a/composer.lock +++ b/composer.lock @@ -666,16 +666,16 @@ }, { "name": "doctrine/inflector", - "version": "2.0.8", + "version": "2.0.9", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff" + "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/f9301a5b2fb1216b2b08f02ba04dc45423db6bff", - "reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/2930cd5ef353871c821d5c43ed030d39ac8cfe65", + "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65", "shasum": "" }, "require": { @@ -737,7 +737,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.8" + "source": "https://github.com/doctrine/inflector/tree/2.0.9" }, "funding": [ { @@ -753,7 +753,7 @@ "type": "tidelift" } ], - "time": "2023-06-16T13:40:37+00:00" + "time": "2024-01-15T18:05:13+00:00" }, { "name": "doctrine/lexer", @@ -1506,16 +1506,16 @@ }, { "name": "laravel/framework", - "version": "v10.40.0", + "version": "v10.41.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "7a9470071dac9579ebf29ad1b9d73e4b8eb586fc" + "reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/7a9470071dac9579ebf29ad1b9d73e4b8eb586fc", - "reference": "7a9470071dac9579ebf29ad1b9d73e4b8eb586fc", + "url": "https://api.github.com/repos/laravel/framework/zipball/da31969bd35e6ee0bbcd9e876f88952dc754b012", + "reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012", "shasum": "" }, "require": { @@ -1707,20 +1707,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-01-09T11:46:47+00:00" + "time": "2024-01-16T15:23:58+00:00" }, { "name": "laravel/prompts", - "version": "v0.1.14", + "version": "v0.1.15", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6" + "reference": "d814a27514d99b03c85aa42b22cfd946568636c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", - "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", + "url": "https://api.github.com/repos/laravel/prompts/zipball/d814a27514d99b03c85aa42b22cfd946568636c1", + "reference": "d814a27514d99b03c85aa42b22cfd946568636c1", "shasum": "" }, "require": { @@ -1762,9 +1762,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.14" + "source": "https://github.com/laravel/prompts/tree/v0.1.15" }, - "time": "2023-12-27T04:18:09+00:00" + "time": "2023-12-29T22:37:42+00:00" }, { "name": "laravel/sanctum", @@ -1834,40 +1834,42 @@ }, { "name": "laravel/scout", - "version": "v10.6.1", + "version": "v10.8.0", "source": { "type": "git", "url": "https://github.com/laravel/scout.git", - "reference": "fc9bc0c2061eb54b31d9dba0999755177a8f1a0e" + "reference": "c74d0081fe099fd6bcddddefed13b5cd2d6511a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/scout/zipball/fc9bc0c2061eb54b31d9dba0999755177a8f1a0e", - "reference": "fc9bc0c2061eb54b31d9dba0999755177a8f1a0e", + "url": "https://api.github.com/repos/laravel/scout/zipball/c74d0081fe099fd6bcddddefed13b5cd2d6511a0", + "reference": "c74d0081fe099fd6bcddddefed13b5cd2d6511a0", "shasum": "" }, "require": { - "illuminate/bus": "^9.0|^10.0", - "illuminate/contracts": "^9.0|^10.0", - "illuminate/database": "^9.0|^10.0", - "illuminate/http": "^9.0|^10.0", - "illuminate/pagination": "^9.0|^10.0", - "illuminate/queue": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", + "illuminate/bus": "^9.0|^10.0|^11.0", + "illuminate/contracts": "^9.0|^10.0|^11.0", + "illuminate/database": "^9.0|^10.0|^11.0", + "illuminate/http": "^9.0|^10.0|^11.0", + "illuminate/pagination": "^9.0|^10.0|^11.0", + "illuminate/queue": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0", "php": "^8.0" }, "require-dev": { "algolia/algoliasearch-client-php": "^3.2", "meilisearch/meilisearch-php": "^1.0", "mockery/mockery": "^1.0", - "orchestra/testbench": "^7.31|^8.11", + "orchestra/testbench": "^7.31|^8.11|^9.0", "php-http/guzzle7-adapter": "^1.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.3|^10.4", + "typesense/typesense-php": "^4.9" }, "suggest": { "algolia/algoliasearch-client-php": "Required to use the Algolia engine (^3.2).", - "meilisearch/meilisearch-php": "Required to use the Meilisearch engine (^1.0)." + "meilisearch/meilisearch-php": "Required to use the Meilisearch engine (^1.0).", + "typesense/typesense-php": "Required to use the Typesense engine (^4.9)." }, "type": "library", "extra": { @@ -1905,7 +1907,7 @@ "issues": "https://github.com/laravel/scout/issues", "source": "https://github.com/laravel/scout" }, - "time": "2023-12-05T19:44:31+00:00" + "time": "2024-01-16T17:41:12+00:00" }, { "name": "laravel/serializable-closure", @@ -1969,25 +1971,25 @@ }, { "name": "laravel/tinker", - "version": "v2.8.2", + "version": "v2.9.0", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "b936d415b252b499e8c3b1f795cd4fc20f57e1f3" + "reference": "502e0fe3f0415d06d5db1f83a472f0f3b754bafe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/b936d415b252b499e8c3b1f795cd4fc20f57e1f3", - "reference": "b936d415b252b499e8c3b1f795cd4fc20f57e1f3", + "url": "https://api.github.com/repos/laravel/tinker/zipball/502e0fe3f0415d06d5db1f83a472f0f3b754bafe", + "reference": "502e0fe3f0415d06d5db1f83a472f0f3b754bafe", "shasum": "" }, "require": { - "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "php": "^7.2.5|^8.0", - "psy/psysh": "^0.10.4|^0.11.1", - "symfony/var-dumper": "^4.3.4|^5.0|^6.0" + "psy/psysh": "^0.11.1|^0.12.0", + "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0" }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", @@ -1995,13 +1997,10 @@ "phpunit/phpunit": "^8.5.8|^9.3.3" }, "suggest": { - "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0)." + "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0)." }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - }, "laravel": { "providers": [ "Laravel\\Tinker\\TinkerServiceProvider" @@ -2032,9 +2031,9 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.8.2" + "source": "https://github.com/laravel/tinker/tree/v2.9.0" }, - "time": "2023-08-15T14:27:00+00:00" + "time": "2024-01-04T16:10:04+00:00" }, { "name": "league/commonmark", @@ -2900,16 +2899,16 @@ }, { "name": "nette/utils", - "version": "v4.0.3", + "version": "v4.0.4", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015" + "reference": "d3ad0aa3b9f934602cb3e3902ebccf10be34d218" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/a9d127dd6a203ce6d255b2e2db49759f7506e015", - "reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015", + "url": "https://api.github.com/repos/nette/utils/zipball/d3ad0aa3b9f934602cb3e3902ebccf10be34d218", + "reference": "d3ad0aa3b9f934602cb3e3902ebccf10be34d218", "shasum": "" }, "require": { @@ -2980,9 +2979,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.3" + "source": "https://github.com/nette/utils/tree/v4.0.4" }, - "time": "2023-10-29T21:02:13+00:00" + "time": "2024-01-17T16:50:36+00:00" }, { "name": "nicmart/tree", @@ -4069,25 +4068,25 @@ }, { "name": "psy/psysh", - "version": "v0.11.22", + "version": "v0.12.0", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b" + "reference": "750bf031a48fd07c673dbe3f11f72362ea306d0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/128fa1b608be651999ed9789c95e6e2a31b5802b", - "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/750bf031a48fd07c673dbe3f11f72362ea306d0d", + "reference": "750bf031a48fd07c673dbe3f11f72362ea306d0d", "shasum": "" }, "require": { "ext-json": "*", "ext-tokenizer": "*", - "nikic/php-parser": "^4.0 || ^3.1", - "php": "^8.0 || ^7.0.8", - "symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4", - "symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4" + "nikic/php-parser": "^5.0 || ^4.0", + "php": "^8.0 || ^7.4", + "symfony/console": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4", + "symfony/var-dumper": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4" }, "conflict": { "symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4" @@ -4098,8 +4097,7 @@ "suggest": { "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", "ext-pdo-sqlite": "The doc command requires SQLite to work.", - "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.", - "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history." + "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well." }, "bin": [ "bin/psysh" @@ -4107,7 +4105,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-0.11": "0.11.x-dev" + "dev-main": "0.12.x-dev" }, "bamarni-bin": { "bin-links": false, @@ -4143,9 +4141,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.22" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.0" }, - "time": "2023-10-14T21:56:36+00:00" + "time": "2023-12-20T15:28:09+00:00" }, { "name": "ralouphie/getallheaders", @@ -4509,20 +4507,20 @@ }, { "name": "spatie/laravel-package-tools", - "version": "1.16.1", + "version": "1.16.2", "source": { "type": "git", "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d" + "reference": "e62eeb1fe8a8a0b2e83227a6c279c8c59f7d3a15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/cc7c991555a37f9fa6b814aa03af73f88026a83d", - "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/e62eeb1fe8a8a0b2e83227a6c279c8c59f7d3a15", + "reference": "e62eeb1fe8a8a0b2e83227a6c279c8c59f7d3a15", "shasum": "" }, "require": { - "illuminate/contracts": "^9.28|^10.0", + "illuminate/contracts": "^9.28|^10.0|^11.0", "php": "^8.0" }, "require-dev": { @@ -4557,7 +4555,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.1" + "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.2" }, "funding": [ { @@ -4565,7 +4563,7 @@ "type": "github" } ], - "time": "2023-08-23T09:04:39+00:00" + "time": "2024-01-11T08:43:00+00:00" }, { "name": "spatie/laravel-sitemap", @@ -8832,16 +8830,16 @@ }, { "name": "laravel/breeze", - "version": "v1.27.0", + "version": "v1.28.1", "source": { "type": "git", "url": "https://github.com/laravel/breeze.git", - "reference": "b0ac214483b5cf42fe5a8007d643d0fe9f95e2e1" + "reference": "e853918e770822780efd160a73fd676992340aca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/breeze/zipball/b0ac214483b5cf42fe5a8007d643d0fe9f95e2e1", - "reference": "b0ac214483b5cf42fe5a8007d643d0fe9f95e2e1", + "url": "https://api.github.com/repos/laravel/breeze/zipball/e853918e770822780efd160a73fd676992340aca", + "reference": "e853918e770822780efd160a73fd676992340aca", "shasum": "" }, "require": { @@ -8890,20 +8888,20 @@ "issues": "https://github.com/laravel/breeze/issues", "source": "https://github.com/laravel/breeze" }, - "time": "2023-12-19T14:44:20+00:00" + "time": "2024-01-15T16:14:10+00:00" }, { "name": "laravel/dusk", - "version": "v7.12.0", + "version": "v7.12.1", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "94534fa924600e7a103f177d41b74e9b94f0994d" + "reference": "e7c2509034753dd4b2339b082884eef357673bf7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/94534fa924600e7a103f177d41b74e9b94f0994d", - "reference": "94534fa924600e7a103f177d41b74e9b94f0994d", + "url": "https://api.github.com/repos/laravel/dusk/zipball/e7c2509034753dd4b2339b082884eef357673bf7", + "reference": "e7c2509034753dd4b2339b082884eef357673bf7", "shasum": "" }, "require": { @@ -8964,22 +8962,22 @@ ], "support": { "issues": "https://github.com/laravel/dusk/issues", - "source": "https://github.com/laravel/dusk/tree/v7.12.0" + "source": "https://github.com/laravel/dusk/tree/v7.12.1" }, - "time": "2023-12-05T15:05:04+00:00" + "time": "2024-01-03T22:54:48+00:00" }, { "name": "laravel/pint", - "version": "v1.13.7", + "version": "v1.13.9", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "4157768980dbd977f1c4b4cc94997416d8b30ece" + "reference": "e3e269cc5d874c8efd2dc7962b1c7ff2585fe525" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/4157768980dbd977f1c4b4cc94997416d8b30ece", - "reference": "4157768980dbd977f1c4b4cc94997416d8b30ece", + "url": "https://api.github.com/repos/laravel/pint/zipball/e3e269cc5d874c8efd2dc7962b1c7ff2585fe525", + "reference": "e3e269cc5d874c8efd2dc7962b1c7ff2585fe525", "shasum": "" }, "require": { @@ -8990,13 +8988,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.38.0", - "illuminate/view": "^10.30.1", + "friendsofphp/php-cs-fixer": "^3.47.0", + "illuminate/view": "^10.40.0", + "larastan/larastan": "^2.8.1", "laravel-zero/framework": "^10.3.0", - "mockery/mockery": "^1.6.6", - "nunomaduro/larastan": "^2.6.4", + "mockery/mockery": "^1.6.7", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.24.2" + "pestphp/pest": "^2.31.0" }, "bin": [ "builds/pint" @@ -9032,20 +9030,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-12-05T19:43:12+00:00" + "time": "2024-01-16T17:39:29+00:00" }, { "name": "laravel/sail", - "version": "v1.26.3", + "version": "v1.27.1", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "fa1ad5fbb03686dfc752bfd1861d86091cc1c32d" + "reference": "9dc648978e4276f2bfd37a076a52e3bd9394777f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/fa1ad5fbb03686dfc752bfd1861d86091cc1c32d", - "reference": "fa1ad5fbb03686dfc752bfd1861d86091cc1c32d", + "url": "https://api.github.com/repos/laravel/sail/zipball/9dc648978e4276f2bfd37a076a52e3bd9394777f", + "reference": "9dc648978e4276f2bfd37a076a52e3bd9394777f", "shasum": "" }, "require": { @@ -9097,7 +9095,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2023-12-02T18:26:39+00:00" + "time": "2024-01-13T18:46:48+00:00" }, { "name": "mockery/mockery", @@ -9639,24 +9637,24 @@ }, { "name": "orchestra/testbench", - "version": "v8.19.0", + "version": "v8.21.0", "source": { "type": "git", "url": "https://github.com/orchestral/testbench.git", - "reference": "a3c7b35102f76135962451324703738f5551d46b" + "reference": "f2860d424e8ef7eb445b1081eab2a54d493e14b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench/zipball/a3c7b35102f76135962451324703738f5551d46b", - "reference": "a3c7b35102f76135962451324703738f5551d46b", + "url": "https://api.github.com/repos/orchestral/testbench/zipball/f2860d424e8ef7eb445b1081eab2a54d493e14b5", + "reference": "f2860d424e8ef7eb445b1081eab2a54d493e14b5", "shasum": "" }, "require": { "composer-runtime-api": "^2.2", "fakerphp/faker": "^1.21", - "laravel/framework": "^10.39", + "laravel/framework": "^10.40", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^8.19", + "orchestra/testbench-core": "^8.21", "orchestra/workbench": "^1.2 || ^8.2", "php": "^8.1", "phpunit/phpunit": "^9.6 || ^10.1", @@ -9688,22 +9686,22 @@ ], "support": { "issues": "https://github.com/orchestral/testbench/issues", - "source": "https://github.com/orchestral/testbench/tree/v8.19.0" + "source": "https://github.com/orchestral/testbench/tree/v8.21.0" }, - "time": "2023-12-28T14:58:57+00:00" + "time": "2024-01-19T14:57:29+00:00" }, { "name": "orchestra/testbench-core", - "version": "v8.19.0", + "version": "v8.21.0", "source": { "type": "git", "url": "https://github.com/orchestral/testbench-core.git", - "reference": "15645dd792968f48a27a26fc4f542c16d9f07e0d" + "reference": "34038bbc26dfb2305297c664efad1d5be3918ee2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/15645dd792968f48a27a26fc4f542c16d9f07e0d", - "reference": "15645dd792968f48a27a26fc4f542c16d9f07e0d", + "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/34038bbc26dfb2305297c664efad1d5be3918ee2", + "reference": "34038bbc26dfb2305297c664efad1d5be3918ee2", "shasum": "" }, "require": { @@ -9713,14 +9711,15 @@ }, "conflict": { "brianium/paratest": "<6.4.0 || >=7.0.0 <7.1.4 || >=8.0.0", - "laravel/framework": "<10.39 || >=11.0.0", + "laravel/framework": "<10.40 || >=11.0.0", "nunomaduro/collision": "<6.4.0 || >=7.0.0 <7.4.0 || >=8.0.0", + "orchestra/testbench-dusk": "<8.21.0 || >=9.0.0", "orchestra/workbench": "<1.0.0", - "phpunit/phpunit": "<9.6.0 || 10.5.4 || >=10.6.0" + "phpunit/phpunit": "<9.6.0 || >=10.6.0" }, "require-dev": { "fakerphp/faker": "^1.21", - "laravel/framework": "^10.39", + "laravel/framework": "^10.40", "laravel/pint": "^1.6", "mockery/mockery": "^1.5.1", "phpstan/phpstan": "^1.10.7", @@ -9734,14 +9733,15 @@ "brianium/paratest": "Allow using parallel testing (^6.4 || ^7.1.4).", "ext-pcntl": "Required to use all features of the console signal trapping.", "fakerphp/faker": "Allow using Faker for testing (^1.21).", - "laravel/framework": "Required for testing (^10.39).", + "laravel/framework": "Required for testing (^10.40).", "mockery/mockery": "Allow using Mockery for testing (^1.5.1).", "nunomaduro/collision": "Allow using Laravel style tests output and parallel testing (^6.4 || ^7.4).", "orchestra/testbench-browser-kit": "Allow using legacy Laravel BrowserKit for testing (^8.0).", "orchestra/testbench-dusk": "Allow using Laravel Dusk for testing (^8.0).", "phpunit/phpunit": "Allow using PHPUnit for testing (^9.6 || ^10.1).", - "symfony/yaml": "Required for CLI Commander (^6.2).", - "vlucas/phpdotenv": "Required for CLI Commander (^5.4.1)." + "symfony/process": "Required to use Orchestra\\Testbench\\remote function (^6.2).", + "symfony/yaml": "Required for Testbench CLI (^6.2).", + "vlucas/phpdotenv": "Required for Testbench CLI (^5.4.1)." }, "bin": [ "testbench" @@ -9780,7 +9780,7 @@ "issues": "https://github.com/orchestral/testbench/issues", "source": "https://github.com/orchestral/testbench-core" }, - "time": "2023-12-28T14:44:29+00:00" + "time": "2024-01-19T14:40:27+00:00" }, { "name": "orchestra/workbench", @@ -10141,16 +10141,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", "shasum": "" }, "require": { @@ -10193,9 +10193,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-01-11T11:49:22+00:00" }, { "name": "phpmyadmin/sql-parser", @@ -10333,16 +10333,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.55", + "version": "1.10.56", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949" + "reference": "27816a01aea996191ee14d010f325434c0ee76fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", - "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/27816a01aea996191ee14d010f325434c0ee76fa", + "reference": "27816a01aea996191ee14d010f325434c0ee76fa", "shasum": "" }, "require": { @@ -10391,7 +10391,7 @@ "type": "tidelift" } ], - "time": "2024-01-08T12:32:40+00:00" + "time": "2024-01-15T10:43:00+00:00" }, { "name": "phpunit/php-code-coverage", @@ -10716,16 +10716,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.5", + "version": "10.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" + "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/08f4fa74d5fbfff1ef22abffee47aaedcaea227e", + "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e", "shasum": "" }, "require": { @@ -10797,7 +10797,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.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.8" }, "funding": [ { @@ -10813,7 +10813,7 @@ "type": "tidelift" } ], - "time": "2023-12-27T15:13:52+00:00" + "time": "2024-01-19T07:07:27+00:00" }, { "name": "pimple/pimple", @@ -12185,16 +12185,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "2.4.0", + "version": "2.4.1", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "b9395ba48d3f30d42092cf6ceff75ed7256cd604" + "reference": "005e1e7b1232f3b22d7e7be3f602693efc7dba67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/b9395ba48d3f30d42092cf6ceff75ed7256cd604", - "reference": "b9395ba48d3f30d42092cf6ceff75ed7256cd604", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/005e1e7b1232f3b22d7e7be3f602693efc7dba67", + "reference": "005e1e7b1232f3b22d7e7be3f602693efc7dba67", "shasum": "" }, "require": { @@ -12273,7 +12273,7 @@ "type": "github" } ], - "time": "2024-01-04T14:51:24+00:00" + "time": "2024-01-12T13:14:58+00:00" }, { "name": "spatie/laravel-ray", @@ -12818,29 +12818,29 @@ }, { "name": "tightenco/duster", - "version": "v2.7.2", + "version": "v2.7.3", "source": { "type": "git", "url": "https://github.com/tighten/duster.git", - "reference": "84fcb71992b6a70c1741f056ed17ae14dd9c847f" + "reference": "6d1a598bd3cc13d61e7cda17b4ae4deffce0e0e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tighten/duster/zipball/84fcb71992b6a70c1741f056ed17ae14dd9c847f", - "reference": "84fcb71992b6a70c1741f056ed17ae14dd9c847f", + "url": "https://api.github.com/repos/tighten/duster/zipball/6d1a598bd3cc13d61e7cda17b4ae4deffce0e0e4", + "reference": "6d1a598bd3cc13d61e7cda17b4ae4deffce0e0e4", "shasum": "" }, "require": { "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.21.1", - "laravel-zero/framework": "^10.1.1", - "laravel/pint": "^v1.11.0", - "nunomaduro/termwind": "^1.15.1", + "friendsofphp/php-cs-fixer": "^3.46", + "laravel-zero/framework": "^10.3", + "laravel/pint": "^1.13", + "nunomaduro/termwind": "^1.15", "spatie/invade": "^1.1", - "squizlabs/php_codesniffer": "^3.7.2", - "tightenco/tlint": "^9.0" + "squizlabs/php_codesniffer": "^3.8", + "tightenco/tlint": "^9.2" }, "bin": [ "builds/duster" @@ -12884,20 +12884,20 @@ "issues": "https://github.com/tighten/duster/issues", "source": "https://github.com/tighten/duster" }, - "time": "2024-01-05T20:30:54+00:00" + "time": "2024-01-12T23:26:01+00:00" }, { "name": "vimeo/psalm", - "version": "5.18.0", + "version": "5.20.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "b113f3ed0259fd6e212d87c3df80eec95a6abf19" + "reference": "3f284e96c9d9be6fe6b15c79416e1d1903dcfef4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/b113f3ed0259fd6e212d87c3df80eec95a6abf19", - "reference": "b113f3ed0259fd6e212d87c3df80eec95a6abf19", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/3f284e96c9d9be6fe6b15c79416e1d1903dcfef4", + "reference": "3f284e96c9d9be6fe6b15c79416e1d1903dcfef4", "shasum": "" }, "require": { @@ -12994,7 +12994,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2023-12-16T09:37:35+00:00" + "time": "2024-01-18T12:15:06+00:00" }, { "name": "zbateson/mail-mime-parser", diff --git a/database/factories/NameListFactory.php b/database/factories/NameListFactory.php index 9fbd5cc..6f9de16 100644 --- a/database/factories/NameListFactory.php +++ b/database/factories/NameListFactory.php @@ -24,6 +24,7 @@ public function definition(): array 'is_public' => fake()->boolean, 'can_be_modified' => fake()->boolean, 'is_list_of_favorites' => fake()->boolean, + 'uuid' => fake()->uuid, ]; } } diff --git a/database/factories/NoteFactory.php b/database/factories/NoteFactory.php new file mode 100644 index 0000000..c161a7e --- /dev/null +++ b/database/factories/NoteFactory.php @@ -0,0 +1,29 @@ + + */ +class NoteFactory extends Factory +{ + protected static ?string $password; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'user_id' => User::factory(), + 'name_id' => Name::factory(), + 'content' => fake()->sentence(), + ]; + } +} diff --git a/database/migrations/2023_12_27_025637_create_lists_table.php b/database/migrations/2023_12_27_025637_create_lists_table.php index d2093bb..d1a41ee 100644 --- a/database/migrations/2023_12_27_025637_create_lists_table.php +++ b/database/migrations/2023_12_27_025637_create_lists_table.php @@ -14,6 +14,7 @@ public function up(): void Schema::create('lists', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('user_id'); + $table->string('uuid')->nullable(); $table->string('name')->nullable(); $table->string('description')->nullable(); $table->boolean('is_public')->default(true); diff --git a/database/migrations/2024_01_16_223956_create_name_user_table.php b/database/migrations/2024_01_16_223956_create_name_user_table.php new file mode 100644 index 0000000..6c61fb2 --- /dev/null +++ b/database/migrations/2024_01_16_223956_create_name_user_table.php @@ -0,0 +1,24 @@ +id(); + $table->unsignedBigInteger('user_id'); + $table->unsignedBigInteger('name_id'); + $table->string('content'); + $table->timestamps(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->foreign('name_id')->references('id')->on('names')->onDelete('cascade'); + }); + } +}; diff --git a/package.json b/package.json index 2573e3f..ffc8ae1 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "vite": "^4.0.0" }, "dependencies": { + "@ryangjchandler/alpine-clipboard": "^2.3.0", "@tailwindcss/forms": "^0.5.2", "@tailwindcss/typography": "^0.5.10", "alpinejs": "^3.4.2", diff --git a/resources/css/app.css b/resources/css/app.css index 21b94e1..0fcef93 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -20,3 +20,7 @@ grid-template-columns: 1fr; } } + +[x-cloak] { + display: none !important; +} diff --git a/resources/js/app.js b/resources/js/app.js index 6f35946..e22d0c2 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,10 +1,13 @@ import './bootstrap'; import Alpine from 'alpinejs'; +import Clipboard from "@ryangjchandler/alpine-clipboard"; import htmx from 'htmx.org'; import 'charts.css'; window.Alpine = Alpine; window.htmx = htmx; +Alpine.plugin(Clipboard); +window.Alpine = Alpine; Alpine.start(); diff --git a/resources/views/components/note-show.blade.php b/resources/views/components/note-show.blade.php new file mode 100644 index 0000000..36d0451 --- /dev/null +++ b/resources/views/components/note-show.blade.php @@ -0,0 +1,39 @@ +@props(['note', 'url', 'deleteUrl']) + +@if ($note != '') + +
+
+ Note privée + +
    +
  • Editer
  • +
  • Supprimer
  • +
+
+
+ {!! $note !!} +
+
+ +@else + +
+

Ajoutez une note privée à ce prénom.

+ @auth + + + Ajouter + + @else + + + Ajouter + + @endauth +
+ +@endif diff --git a/resources/views/names/partials/edit-note.blade.php b/resources/views/names/partials/edit-note.blade.php new file mode 100644 index 0000000..a4cc037 --- /dev/null +++ b/resources/views/names/partials/edit-note.blade.php @@ -0,0 +1,21 @@ +
+
+ {{ old('note', $note) }} + + +
+ +
+ + + Annuler +
+
diff --git a/resources/views/names/show.blade.php b/resources/views/names/show.blade.php index 9fff547..cf2749d 100644 --- a/resources/views/names/show.blade.php +++ b/resources/views/names/show.blade.php @@ -65,22 +65,22 @@
@@ -108,6 +108,11 @@ + +
+ +
+

@@ -189,7 +194,7 @@ @if (count($lists) !== 0)
-

Vous pouvez aussi l'ajouter à une ou plusieurs listes :

+

Vous pouvez aussi l'ajouter à une ou plusieurs listes en cliquant sur le petit plus :

@forelse ($lists['lists'] as $list) diff --git a/resources/views/user/index.blade.php b/resources/views/user/index.blade.php index 83563dd..c25a6cc 100644 --- a/resources/views/user/index.blade.php +++ b/resources/views/user/index.blade.php @@ -44,6 +44,9 @@ class="flex items-center justify-between border border-transparent hover:bg-gray
{{ $name['name'] }}

{{ $name['total'] }} utilisations depuis 1900

+ @if ($name['note']) +

{{ $name['note'] }}

+ @endif
diff --git a/resources/views/user/lists/index.blade.php b/resources/views/user/lists/index.blade.php index 5df82f0..0a177fd 100644 --- a/resources/views/user/lists/index.blade.php +++ b/resources/views/user/lists/index.blade.php @@ -24,6 +24,10 @@

Une liste vous permet de classer vos prénoms autour d'une thématique donnée.

+ + @endif diff --git a/resources/views/user/lists/show.blade.php b/resources/views/user/lists/show.blade.php index 3122d4d..0008eac 100644 --- a/resources/views/user/lists/show.blade.php +++ b/resources/views/user/lists/show.blade.php @@ -20,19 +20,62 @@
-
+

{{ $list['name'] }}

@if ($list['description'] !== null)

{{ $list['description'] }}

@endif -
    -
  • Editer
  • -
  • Supprimer
  • -
+
+
+ + + + Ajouter un prénom à la liste + + +
+
+ + + Partager la liste et activer les votes + +
+ + +
+ +
+

Pour permettre aux gens de voter sur cette liste, copier le lien ci-dessous et envoyez le à ceux qui comptent. Voter sur la liste ne nécessite pas de compte. De plus, chaque personne qui recoit le lien aura droit à un vote.

+

Vous pourrez réinitialiser les votes quand vous voudrez.

+
+ + +
+
-
+
@include('user.lists.partials.search-items')
diff --git a/routes/web.php b/routes/web.php index 6a52437..5b3c9a4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,16 +6,17 @@ use App\Http\Controllers\ListController; use App\Http\Controllers\ListNameController; use App\Http\Controllers\ListSearchController; -use App\Http\Controllers\LocaleController; use App\Http\Controllers\MaleNameController; use App\Http\Controllers\MixteNameController; use App\Http\Controllers\NameController; use App\Http\Controllers\NameFavoriteController; use App\Http\Controllers\ProfileController; use App\Http\Controllers\SearchController; +use App\Http\Controllers\ShareController; +use App\Http\Controllers\UserNameController; use Illuminate\Support\Facades\Route; -Route::get('locale/{locale}', [LocaleController::class, 'update'])->name('locale.update'); +Route::get('partage/{uuid}', [ShareController::class, 'show'])->name('share.show'); Route::get('', [HomeController::class, 'index'])->name('home.index'); Route::get('recherche', [SearchController::class, 'index'])->name('search.index'); @@ -46,6 +47,12 @@ // used on the show page Route::put('prenoms/{id}/show/favorite', [NameFavoriteController::class, 'update'])->name('favorite.name.update'); + + // set the note for the given name + Route::get('notes/{id}', [UserNameController::class, 'show'])->name('user.name.show'); + Route::get('notes/{id}/edit', [UserNameController::class, 'edit'])->name('user.name.edit'); + Route::put('notes/{id}', [UserNameController::class, 'update'])->name('user.name.update'); + Route::delete('notes/{id}', [UserNameController::class, 'destroy'])->name('user.name.destroy'); }); Route::get('favoris', [FavoriteController::class, 'index'])->name('favorite.index'); diff --git a/tests/Unit/Models/NameTest.php b/tests/Unit/Models/NameTest.php index e7a5026..81ecef5 100644 --- a/tests/Unit/Models/NameTest.php +++ b/tests/Unit/Models/NameTest.php @@ -5,6 +5,8 @@ use App\Models\Name; use App\Models\NameList; use App\Models\NameStatistic; +use App\Models\Note; +use App\Models\User; use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; @@ -32,4 +34,22 @@ public function it_has_many_name_lists(): void $this->assertTrue($name->lists()->exists()); } + + /** @test */ + public function it_gets_the_content_of_the_note_for_the_user_if_it_is_set(): void + { + $name = Name::factory()->create(); + $user = User::factory()->create(); + $this->be($user); + Note::factory()->create([ + 'name_id' => $name->id, + 'user_id' => $user->id, + 'content' => 'This is a note', + ]); + + $this->assertEquals( + 'This is a note', + $name->getNoteForUser() + ); + } } diff --git a/tests/Unit/Models/NoteTest.php b/tests/Unit/Models/NoteTest.php new file mode 100644 index 0000000..2b08e4f --- /dev/null +++ b/tests/Unit/Models/NoteTest.php @@ -0,0 +1,36 @@ +create(); + $note = Note::factory()->create([ + 'name_id' => $name->id, + ]); + + $this->assertTrue($note->name()->exists()); + } + + /** @test */ + public function it_belongs_to_a_user(): void + { + $user = User::factory()->create(); + $note = Note::factory()->create([ + 'user_id' => $user->id, + ]); + + $this->assertTrue($note->user()->exists()); + } +} diff --git a/tests/Unit/ViewModels/Names/NameViewModelTest.php b/tests/Unit/ViewModels/Names/NameViewModelTest.php index b73ec1b..bcc56b5 100644 --- a/tests/Unit/ViewModels/Names/NameViewModelTest.php +++ b/tests/Unit/ViewModels/Names/NameViewModelTest.php @@ -78,6 +78,7 @@ public function it_gets_the_details_of_a_name(): void [ 'show' => env('APP_URL') . '/prenoms/' . $name->id . '/heloise', 'favorite' => env('APP_URL') . '/prenoms/' . $name->id . '/show/favorite', + 'note_edit' => env('APP_URL') . '/notes/' . $name->id, ], $array['url'] ); diff --git a/tests/Unit/ViewModels/User/ListViewModelTest.php b/tests/Unit/ViewModels/User/ListViewModelTest.php index 0d73f9f..3efb8dc 100644 --- a/tests/Unit/ViewModels/User/ListViewModelTest.php +++ b/tests/Unit/ViewModels/User/ListViewModelTest.php @@ -57,6 +57,7 @@ public function it_gets_the_list_of_names_in_the_list(): void $user = User::factory()->create(); $nameList = $user->lists()->create([ 'is_list_of_favorites' => true, + 'uuid' => '1234567890', ]); $nameList->names()->attach($name->id); @@ -64,18 +65,19 @@ public function it_gets_the_list_of_names_in_the_list(): void $array = ListViewModel::show($nameList); - $this->assertCount(5, $array); + $this->assertCount(6, $array); $this->assertArrayHasKey('id', $array); $this->assertArrayHasKey('name', $array); $this->assertArrayHasKey('description', $array); $this->assertArrayHasKey('names', $array); + $this->assertArrayHasKey('uuid', $array); $this->assertArrayHasKey('url', $array); $this->assertEquals( [ 0 => [ 'id' => $name->id, - 'name' => 'Test', 'total' => '1 000', + 'name' => 'Test', 'url' => [ 'show' => env('APP_URL') . '/prenoms/' . $name->id . '/test', 'destroy' => env('APP_URL') . '/listes/' . $nameList->id . '/prenoms/' . $name->id, diff --git a/tests/Unit/ViewModels/User/UserViewModelTest.php b/tests/Unit/ViewModels/User/UserViewModelTest.php index ca9fa6b..501f32b 100644 --- a/tests/Unit/ViewModels/User/UserViewModelTest.php +++ b/tests/Unit/ViewModels/User/UserViewModelTest.php @@ -4,6 +4,7 @@ use App\Http\ViewModels\User\UserViewModel; use App\Models\Name; +use App\Models\Note; use App\Models\User; use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; @@ -46,6 +47,11 @@ public function it_gets_the_list_of_favorites_for_the_index_page(): void 'is_list_of_favorites' => true, ]); $nameList->names()->attach($name->id); + Note::factory()->create([ + 'name_id' => $name->id, + 'user_id' => $user->id, + 'content' => 'this is a note', + ]); $this->be($user); @@ -57,6 +63,7 @@ public function it_gets_the_list_of_favorites_for_the_index_page(): void 'id' => $name->id, 'name' => 'Test', 'total' => '1 000', + 'note' => 'this is a note', 'url' => [ 'show' => env('APP_URL') . '/prenoms/' . $name->id . '/test', 'favorite' => env('APP_URL') . '/prenoms/' . $name->id . '/favorite',