From 8df37d01190c532e7c9e0f493c15d1d79589c8ba Mon Sep 17 00:00:00 2001 From: Mazarin Date: Sat, 23 Dec 2023 10:37:09 -0500 Subject: [PATCH] chore: wip (#9) --- .../Commands/CreateMainCharacteristics.php | 73 +++++++ app/Console/Commands/FetchMetaData.php | 16 +- app/Helpers/OpenAIHelper.php | 42 +++- .../Auth/RegisteredUserController.php | 5 - app/Http/Controllers/SearchController.php | 40 ++++ .../Settings/SettingsLevelController.php | 96 --------- .../Settings/SettingsProfileController.php | 14 -- .../Settings/SettingsRoleController.php | 96 --------- app/Http/Kernel.php | 1 - .../Middleware/CheckAdministratorRole.php | 28 --- app/Http/ViewModels/Names/NameViewModel.php | 12 +- .../ViewModels/Search/SearchViewModel.php | 35 ++++ .../Settings/SettingsLevelViewModel.php | 28 --- .../Settings/SettingsRoleViewModel.php | 28 --- app/Jobs/PopulateAccount.php | 79 -------- app/Jobs/ProcessMainCaracteristics.php | 39 ++++ app/Jobs/ProcessMixte.php | 4 +- app/Jobs/ProcessSyllabes.php | 37 ++++ app/Models/Characteristic.php | 25 +++ app/Models/Level.php | 31 --- app/Models/Name.php | 24 ++- app/Models/Organization.php | 29 --- app/Models/Role.php | 34 ---- app/Models/User.php | 12 -- app/Services/CreateAccount.php | 21 -- app/Services/CreateLevel.php | 41 ---- app/Services/CreateRole.php | 41 ---- app/Services/DestroyLevel.php | 44 ----- app/Services/DestroyRole.php | 44 ----- app/Services/UpdateLevel.php | 49 ----- app/Services/UpdateRole.php | 49 ----- app/Traits/Translatable.php | 28 --- app/View/Components/LoginLayout.php | 17 ++ bun.lockb | Bin 90684 -> 90685 bytes composer.json | 1 + composer.lock | 186 +++++++++++++----- config/scout.php | 142 +++++++++++++ database/factories/LevelFactory.php | 26 --- database/factories/OrganizationFactory.php | 23 --- database/factories/RoleFactory.php | 26 --- database/factories/UserFactory.php | 7 - ...4_13_002417_create_organizations_table.php | 18 -- .../2014_10_12_000000_create_users_table.php | 7 - .../2023_11_13_200951_create_roles_table.php | 32 --- .../2023_12_08_013120_create_name_table.php | 2 + ...21_004721_create_characteristics_table.php | 29 +++ resources/views/auth/login.blade.php | 4 +- resources/views/auth/register.blade.php | 62 +----- resources/views/layouts/footer.blade.php | 5 + resources/views/layouts/guest.blade.php | 12 +- resources/views/layouts/login.blade.php | 39 ++++ .../layouts/unlogged-navigation.blade.php | 3 + resources/views/names/show.blade.php | 14 +- resources/views/search/index.blade.php | 43 ++++ .../views/search/partials/results.blade.php | 8 + routes/web.php | 27 +-- tests/Browser/SettingsRolesAndLevelsTest.php | 105 ---------- tests/Feature/Auth/RegistrationTest.php | 3 - tests/Feature/Settings/ManageLevelTest.php | 104 ---------- tests/Feature/Settings/ManageRoleTest.php | 104 ---------- tests/Unit/Jobs/PopulateAccountTest.php | 31 --- tests/Unit/Models/LevelTest.php | 19 -- tests/Unit/Models/OrganizationTest.php | 32 --- tests/Unit/Models/RoleTest.php | 19 -- tests/Unit/Models/UserTest.php | 24 --- tests/Unit/Services/CreateAccountTest.php | 19 -- tests/Unit/Services/CreateLevelTest.php | 51 ----- tests/Unit/Services/CreateRoleTest.php | 51 ----- tests/Unit/Services/DestroyLevelTest.php | 63 ------ tests/Unit/Services/DestroyRoleTest.php | 63 ------ tests/Unit/Services/UpdateLevelTest.php | 71 ------- tests/Unit/Services/UpdateRoleTest.php | 71 ------- tests/Unit/Traits/TranslatableTest.php | 36 ---- .../Names/AllNamesViewModelTest.php | 2 +- .../Names/FemaleNamesViewModelTest.php | 2 +- .../Names/MaleNamesViewModelTest.php | 2 +- .../ViewModels/Names/NameViewModelTest.php | 7 +- .../Settings/SettingsLevelViewModelTest.php | 44 ----- .../Settings/SettingsRoleViewModelTest.php | 44 ----- 79 files changed, 790 insertions(+), 2055 deletions(-) create mode 100644 app/Console/Commands/CreateMainCharacteristics.php create mode 100644 app/Http/Controllers/SearchController.php delete mode 100644 app/Http/Controllers/Settings/SettingsLevelController.php delete mode 100644 app/Http/Controllers/Settings/SettingsProfileController.php delete mode 100644 app/Http/Controllers/Settings/SettingsRoleController.php delete mode 100644 app/Http/Middleware/CheckAdministratorRole.php create mode 100644 app/Http/ViewModels/Search/SearchViewModel.php delete mode 100644 app/Http/ViewModels/Settings/SettingsLevelViewModel.php delete mode 100644 app/Http/ViewModels/Settings/SettingsRoleViewModel.php delete mode 100644 app/Jobs/PopulateAccount.php create mode 100644 app/Jobs/ProcessMainCaracteristics.php create mode 100644 app/Jobs/ProcessSyllabes.php create mode 100644 app/Models/Characteristic.php delete mode 100644 app/Models/Level.php delete mode 100644 app/Models/Organization.php delete mode 100644 app/Models/Role.php delete mode 100644 app/Services/CreateLevel.php delete mode 100644 app/Services/CreateRole.php delete mode 100644 app/Services/DestroyLevel.php delete mode 100644 app/Services/DestroyRole.php delete mode 100644 app/Services/UpdateLevel.php delete mode 100644 app/Services/UpdateRole.php delete mode 100644 app/Traits/Translatable.php create mode 100644 app/View/Components/LoginLayout.php create mode 100644 config/scout.php delete mode 100644 database/factories/LevelFactory.php delete mode 100644 database/factories/OrganizationFactory.php delete mode 100644 database/factories/RoleFactory.php delete mode 100644 database/migrations/2014_04_13_002417_create_organizations_table.php delete mode 100644 database/migrations/2023_11_13_200951_create_roles_table.php create mode 100644 database/migrations/2023_12_21_004721_create_characteristics_table.php create mode 100644 resources/views/layouts/footer.blade.php create mode 100644 resources/views/layouts/login.blade.php create mode 100644 resources/views/search/index.blade.php create mode 100644 resources/views/search/partials/results.blade.php delete mode 100644 tests/Browser/SettingsRolesAndLevelsTest.php delete mode 100644 tests/Feature/Settings/ManageLevelTest.php delete mode 100644 tests/Feature/Settings/ManageRoleTest.php delete mode 100644 tests/Unit/Jobs/PopulateAccountTest.php delete mode 100644 tests/Unit/Models/LevelTest.php delete mode 100644 tests/Unit/Models/OrganizationTest.php delete mode 100644 tests/Unit/Models/RoleTest.php delete mode 100644 tests/Unit/Models/UserTest.php delete mode 100644 tests/Unit/Services/CreateLevelTest.php delete mode 100644 tests/Unit/Services/CreateRoleTest.php delete mode 100644 tests/Unit/Services/DestroyLevelTest.php delete mode 100644 tests/Unit/Services/DestroyRoleTest.php delete mode 100644 tests/Unit/Services/UpdateLevelTest.php delete mode 100644 tests/Unit/Services/UpdateRoleTest.php delete mode 100644 tests/Unit/Traits/TranslatableTest.php delete mode 100644 tests/Unit/ViewModels/Settings/SettingsLevelViewModelTest.php delete mode 100644 tests/Unit/ViewModels/Settings/SettingsRoleViewModelTest.php diff --git a/app/Console/Commands/CreateMainCharacteristics.php b/app/Console/Commands/CreateMainCharacteristics.php new file mode 100644 index 0000000..952c957 --- /dev/null +++ b/app/Console/Commands/CreateMainCharacteristics.php @@ -0,0 +1,73 @@ +lazy() as $name) { + + if (is_null($name->characteristics)) { + continue; + } + + $strings = explode(',', $name->characteristics); + foreach ($strings as $string) { + // lowercase + $lowercase = Str::lower($string); + + // remove the space at the beginning and the end + $string = Str::of($lowercase)->trim()->__toString(); + + // remove any comma or dot at the end + $string = Str::of($string)->rtrim(',.')->__toString(); + + // count the number of words and skip the word if there is more than 1 + $words = explode(' ', $string); + if (count($words) > 1) { + continue; + } + + $characteristic = Characteristic::firstOrCreate([ + 'name' => $string, + ]); + + $name->mainCharacteristics()->syncWithoutDetaching([$characteristic->id]); + } + } + } +} diff --git a/app/Console/Commands/FetchMetaData.php b/app/Console/Commands/FetchMetaData.php index 830ee02..13abca6 100644 --- a/app/Console/Commands/FetchMetaData.php +++ b/app/Console/Commands/FetchMetaData.php @@ -7,10 +7,12 @@ use App\Jobs\ProcessElficTraits; use App\Jobs\ProcessKlingonName; use App\Jobs\ProcessLitteratureReferences; +use App\Jobs\ProcessMainCaracteristics; use App\Jobs\ProcessMixte; use App\Jobs\ProcessOrigins; use App\Jobs\ProcessPersonality; use App\Jobs\ProcessSimilarNames; +use App\Jobs\ProcessSyllabes; use App\Models\Name; use Illuminate\Console\Command; @@ -72,9 +74,17 @@ public function handle(): void //ProcessKlingonName::dispatch($name); } - // if (is_null($name->unisex)) { - // ProcessMixte::dispatch($name); - // } + if (is_null($name->unisex)) { + ProcessMixte::dispatch($name); + } + + if ($name->syllabes === 0) { + ProcessSyllabes::dispatch($name); + } + + if (is_null($name->characteristics)) { + ProcessMainCaracteristics::dispatch($name); + } } } } diff --git a/app/Helpers/OpenAIHelper.php b/app/Helpers/OpenAIHelper.php index 5b5554f..d5b8bf8 100644 --- a/app/Helpers/OpenAIHelper.php +++ b/app/Helpers/OpenAIHelper.php @@ -167,7 +167,47 @@ public static function getUnisex(string $name): ?string [ 'role' => 'system', 'content' => <<<'PROMPT' -pour le prénom donné par l'utilisateur, indiquez si le prénom est unisexe. répondez uniquement par "oui" ou "non", sans rien d'autres, et sans les guillements bien sur. +pour le prénom donné par l'utilisateur, indiquez si le prénom est mixte/unisexe. répondez uniquement par "oui" ou "non", sans rien ajouter d'autres, et sans les guillements bien sur. +PROMPT, + ], [ + 'role' => 'user', + 'content' => $name, + ], + ], + ]); + + return $response->choices[0]->message->content; + } + + public static function getSyllabes(string $name): ?string + { + $response = OpenAI::chat()->create([ + 'model' => 'gpt-3.5-turbo', + 'messages' => [ + [ + 'role' => 'system', + 'content' => <<<'PROMPT' +pour le prénom donné par l'utilisateur, indique le nombre de syllabes. écris simplement le chiffre, sans rien d'autres. +PROMPT, + ], [ + 'role' => 'user', + 'content' => $name, + ], + ], + ]); + + return $response->choices[0]->message->content; + } + + public static function getMainCharacteristics(string $name): ?string + { + $response = OpenAI::chat()->create([ + 'model' => 'gpt-3.5-turbo', + 'messages' => [ + [ + 'role' => 'system', + 'content' => <<<'PROMPT' +pour le prénom donné par l'utilisateur, donne jusqu'à 3 termes ou qualités qui décrivent la personnalité du prénom. donne la reponse en mettant uniquement les mots, séparés par une virgule, sans rien d'autres. PROMPT, ], [ 'role' => 'user', diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index b072915..95ab112 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -31,8 +31,6 @@ public function create(): View public function store(Request $request): RedirectResponse { $request->validate([ - 'first_name' => ['required', 'string', 'max:255'], - 'last_name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]); @@ -40,9 +38,6 @@ public function store(Request $request): RedirectResponse $user = (new CreateAccount( email: $request->input('email'), password: $request->input('password'), - firstName: $request->input('first_name'), - lastName: $request->input('last_name'), - organizationName: $request->input('organization_name'), ))->execute(); event(new Registered($user)); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php new file mode 100644 index 0000000..39c5774 --- /dev/null +++ b/app/Http/Controllers/SearchController.php @@ -0,0 +1,40 @@ + $stats, + 'names' => SearchViewModel::names(), + ]); + } + + public function post(Request $request): View + { + $stats = Cache::remember('stats', 604800, function () { + return HomeViewModel::serverStats(); + }); + + $term = trim($request->input('term')); + $names = SearchViewModel::names($term); +dd($names); + return view('search.index', [ + 'stats' => $stats, + 'names' => $names, + 'term' => $term, + ]); + } +} diff --git a/app/Http/Controllers/Settings/SettingsLevelController.php b/app/Http/Controllers/Settings/SettingsLevelController.php deleted file mode 100644 index 506100f..0000000 --- a/app/Http/Controllers/Settings/SettingsLevelController.php +++ /dev/null @@ -1,96 +0,0 @@ -header('hx-request') && $request->header('hx-target') == 'levels-index') { - return view('settings.level.partials.index', [ - 'data' => SettingsLevelViewModel::index(), - ]); - } - - return view('settings.level.index', [ - 'data' => SettingsLevelViewModel::index(), - ]); - } - - public function new(): View - { - return view('settings.level.new'); - } - - public function store(Request $request): RedirectResponse - { - $validated = $request->validate([ - 'label' => 'required|string|max:255', - ]); - - (new CreateLevel( - label: $validated['label'], - ))->execute(); - - $request->session()->flash('status', __('The level has been created')); - - return redirect()->route('settings.level.index'); - } - - public function edit(Request $request, Level $level): View|RedirectResponse - { - try { - Level::where('organization_id', auth()->user()->organization_id) - ->findOrFail($level->id); - } catch (ModelNotFoundException) { - return redirect()->route('settings.level.index'); - } - - return view('settings.level.edit', [ - 'data' => SettingsLevelViewModel::level($level), - ]); - } - - public function update(Request $request, Level $level): RedirectResponse - { - $validated = $request->validate([ - 'label' => 'required|string|max:255', - ]); - - (new UpdateLevel( - level: $level, - label: $validated['label'], - ))->execute(); - - $request->session()->flash('status', __('Changes saved')); - - return redirect()->route('settings.level.index'); - } - - public function destroy(Request $request, Level $level): Response - { - try { - Level::where('organization_id', auth()->user()->organization_id) - ->findOrFail($level->id); - } catch (ModelNotFoundException) { - } - - (new DestroyLevel( - level: $level, - ))->execute(); - - return response()->make('', 200, ['HX-Trigger' => 'loadLevels']); - } -} diff --git a/app/Http/Controllers/Settings/SettingsProfileController.php b/app/Http/Controllers/Settings/SettingsProfileController.php deleted file mode 100644 index 30bc183..0000000 --- a/app/Http/Controllers/Settings/SettingsProfileController.php +++ /dev/null @@ -1,14 +0,0 @@ -header('hx-request') && $request->header('hx-target') == 'roles-index') { - return view('settings.role.partials.index', [ - 'data' => SettingsRoleViewModel::index(), - ]); - } - - return view('settings.role.index', [ - 'data' => SettingsRoleViewModel::index(), - ]); - } - - public function new(): View - { - return view('settings.role.new'); - } - - public function store(Request $request): RedirectResponse - { - $validated = $request->validate([ - 'label' => 'required|string|max:255', - ]); - - (new CreateRole( - label: $validated['label'], - ))->execute(); - - $request->session()->flash('status', __('The role has been created')); - - return redirect()->route('settings.role.index'); - } - - public function edit(Request $request, Role $role): View|RedirectResponse - { - try { - Role::where('organization_id', auth()->user()->organization_id) - ->findOrFail($role->id); - } catch (ModelNotFoundException) { - return redirect()->route('settings.role.index'); - } - - return view('settings.role.edit', [ - 'data' => SettingsRoleViewModel::role($role), - ]); - } - - public function update(Request $request, Role $role): RedirectResponse - { - $validated = $request->validate([ - 'label' => 'required|string|max:255', - ]); - - (new UpdateRole( - role: $role, - label: $validated['label'], - ))->execute(); - - $request->session()->flash('status', __('Changes saved')); - - return redirect()->route('settings.role.index'); - } - - public function destroy(Request $request, Role $role): Response - { - try { - Role::where('organization_id', auth()->user()->organization_id) - ->findOrFail($role->id); - } catch (ModelNotFoundException) { - } - - (new DestroyRole( - role: $role, - ))->execute(); - - return response()->make('', 200, ['HX-Trigger' => 'loadRoles']); - } -} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index bbcaa95..21806d5 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -65,7 +65,6 @@ class Kernel extends HttpKernel 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, - 'administrator' => \App\Http\Middleware\CheckAdministratorRole::class, 'name' => \App\Http\Middleware\CheckName::class, 'letter' => \App\Http\Middleware\CheckLetter::class, ]; diff --git a/app/Http/Middleware/CheckAdministratorRole.php b/app/Http/Middleware/CheckAdministratorRole.php deleted file mode 100644 index e96bc15..0000000 --- a/app/Http/Middleware/CheckAdministratorRole.php +++ /dev/null @@ -1,28 +0,0 @@ -user()->permissions === User::ROLE_ADMINISTRATOR || - $request->user()->permissions === User::ROLE_ACCOUNT_MANAGER - ) { - return $next($request); - } - - abort(401); - } -} diff --git a/app/Http/ViewModels/Names/NameViewModel.php b/app/Http/ViewModels/Names/NameViewModel.php index 8faaecf..6e4dc79 100644 --- a/app/Http/ViewModels/Names/NameViewModel.php +++ b/app/Http/ViewModels/Names/NameViewModel.php @@ -19,7 +19,7 @@ public static function details(Name $name): array 'avatar' => $name->avatar, 'origins' => Str::of($name->origins)->markdown(), 'personality' => Str::of($name->personality)->markdown(), - 'country_of_origin' => Str::of($name->country_of_origin)->markdown(), + 'syllabes' => $name->syllabes, 'celebrities' => Str::of($name->celebrities)->markdown(), 'elfic_traits' => Str::of($name->elfic_traits)->markdown(), 'name_day' => Str::of($name->name_day)->markdown(), @@ -55,13 +55,21 @@ public static function popularity(Name $name): array // 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'); + if ($total > 0) { + $decade['percentage'] = Number::format(round($decade['popularity'] / $total * 100), locale: 'fr'); + } else { + $decade['percentage'] = 0; + } return $decade; }); + // calculate the total popularity + $total = $name->total; + return [ 'decades' => $decadesCollection, + 'total' => Number::format($total, locale: 'fr'), ]; } diff --git a/app/Http/ViewModels/Search/SearchViewModel.php b/app/Http/ViewModels/Search/SearchViewModel.php new file mode 100644 index 0000000..291fce8 --- /dev/null +++ b/app/Http/ViewModels/Search/SearchViewModel.php @@ -0,0 +1,35 @@ +where('name', '!=', '_PRENOMS_RARES') + ->orderBy('total', 'desc') + ->take(20) + ->get() + ->map(fn (Name $name) => [ + 'id' => $name->id, + 'name' => StringHelper::formatNameFromDB($name->name), + 'avatar' => $name->avatar, + 'url' => route('name.show', [ + 'id' => $name->id, + 'name' => StringHelper::sanitizeNameForURL($name->name), + ]), + ]); + + return [ + 'names' => $names, + 'total' => $names->count(), + ]; + } +} diff --git a/app/Http/ViewModels/Settings/SettingsLevelViewModel.php b/app/Http/ViewModels/Settings/SettingsLevelViewModel.php deleted file mode 100644 index 02481de..0000000 --- a/app/Http/ViewModels/Settings/SettingsLevelViewModel.php +++ /dev/null @@ -1,28 +0,0 @@ -user()->organization_id) - ->get() - ->map(fn (Level $level) => self::level($level)) - ->sortBy('label'); - - return [ - 'levels' => $levels, - ]; - } - - public static function level(Level $level): array - { - return [ - 'id' => $level->id, - 'label' => $level->label, - ]; - } -} diff --git a/app/Http/ViewModels/Settings/SettingsRoleViewModel.php b/app/Http/ViewModels/Settings/SettingsRoleViewModel.php deleted file mode 100644 index 9197009..0000000 --- a/app/Http/ViewModels/Settings/SettingsRoleViewModel.php +++ /dev/null @@ -1,28 +0,0 @@ -user()->organization_id) - ->get() - ->map(fn (Role $role) => self::role($role)) - ->sortBy('label'); - - return [ - 'roles' => $roles, - ]; - } - - public static function role(Role $role): array - { - return [ - 'id' => $role->id, - 'label' => $role->label, - ]; - } -} diff --git a/app/Jobs/PopulateAccount.php b/app/Jobs/PopulateAccount.php deleted file mode 100644 index eeed22e..0000000 --- a/app/Jobs/PopulateAccount.php +++ /dev/null @@ -1,79 +0,0 @@ -addRoles(); - $this->addLevels(); - } - - private function addRoles(): void - { - $roles = [ - trans_key('Software Engineer'), - trans_key('Quality Assurance Engineer'), - trans_key('Project Manager'), - trans_key('Product Manager'), - trans_key('UI/UX Designer'), - trans_key('Data Analyst/Scientist'), - trans_key('DevOps Engineer'), - trans_key('Technical Support Engineer'), - trans_key('Scrum Master'), - trans_key('Sales/Account Manager'), - trans_key('Technical Writer'), - trans_key('System Administrator'), - trans_key('Chief Executive Officer'), - ]; - - foreach ($roles as $role) { - DB::table('roles')->insert([ - 'organization_id' => $this->organization->id, - 'label' => null, - 'label_translation_key' => $role, - 'created_at' => now(), - ]); - } - } - - private function addLevels(): void - { - $levels = [ - trans_key('Junior'), - trans_key('Intermediate'), - trans_key('Senior'), - trans_key('Staff'), - ]; - - foreach ($levels as $level) { - DB::table('levels')->insert([ - 'organization_id' => $this->organization->id, - 'label' => null, - 'label_translation_key' => $level, - 'created_at' => now(), - ]); - } - } -} diff --git a/app/Jobs/ProcessMainCaracteristics.php b/app/Jobs/ProcessMainCaracteristics.php new file mode 100644 index 0000000..ad47067 --- /dev/null +++ b/app/Jobs/ProcessMainCaracteristics.php @@ -0,0 +1,39 @@ +name->characteristics)) { + $strings = OpenAIHelper::getMainCharacteristics($this->name->name); + + $this->name->characteristics = Str::lower($strings); + $this->name->save(); + } + } +} diff --git a/app/Jobs/ProcessMixte.php b/app/Jobs/ProcessMixte.php index 8631f38..4aa26ba 100644 --- a/app/Jobs/ProcessMixte.php +++ b/app/Jobs/ProcessMixte.php @@ -30,9 +30,9 @@ public function handle(): void if ($this->name->unisex === null) { $answer = OpenAIHelper::getUnisex($this->name->name); - if ($answer == 'yes') { + if ($answer == 'oui') { $answer = true; - } elseif ($answer == 'no') { + } elseif ($answer == 'non') { $answer = false; } else { $answer = null; diff --git a/app/Jobs/ProcessSyllabes.php b/app/Jobs/ProcessSyllabes.php new file mode 100644 index 0000000..8bc3d03 --- /dev/null +++ b/app/Jobs/ProcessSyllabes.php @@ -0,0 +1,37 @@ +name->syllabes === 0) { + $number = OpenAIHelper::getSyllabes($this->name->name); + + $this->name->syllabes = $number; + $this->name->save(); + } + } +} diff --git a/app/Models/Characteristic.php b/app/Models/Characteristic.php new file mode 100644 index 0000000..1265025 --- /dev/null +++ b/app/Models/Characteristic.php @@ -0,0 +1,25 @@ +belongsToMany(Name::class); + } +} diff --git a/app/Models/Level.php b/app/Models/Level.php deleted file mode 100644 index 9d2cb29..0000000 --- a/app/Models/Level.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ - protected $fillable = [ - 'organization_id', - 'label', - 'label_translation_key', - ]; - - public function organization(): BelongsTo - { - return $this->belongsTo(Organization::class); - } -} diff --git a/app/Models/Name.php b/app/Models/Name.php index 9aa000e..acf1f1e 100644 --- a/app/Models/Name.php +++ b/app/Models/Name.php @@ -5,11 +5,13 @@ use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; +use Laravel\Scout\Searchable; class Name extends Model { - use HasFactory; + use HasFactory, Searchable; protected $table = 'names'; @@ -26,6 +28,8 @@ class Name extends Model 'similar_names_in_other_languages', 'klingon_translation', 'unisex', + 'syllabes', + 'characteristics', 'total', 'page_views', ]; @@ -36,6 +40,19 @@ class Name extends Model 'name' => 'string', ]; + /** + * Get the indexable data array for the model. + * + * @return array + */ + public function toSearchableArray(): array + { + return [ + 'id' => (int) $this->id, + 'name' => $this->name, + ]; + } + public function nameStatistics(): HasMany { return $this->hasMany(NameStatistic::class); @@ -55,4 +72,9 @@ protected function avatar(): Attribute } ); } + + public function mainCharacteristics(): BelongsToMany + { + return $this->belongsToMany(Characteristic::class); + } } diff --git a/app/Models/Organization.php b/app/Models/Organization.php deleted file mode 100644 index 861389f..0000000 --- a/app/Models/Organization.php +++ /dev/null @@ -1,29 +0,0 @@ -hasMany(Role::class); - } - - public function levels(): HasMany - { - return $this->hasMany(Level::class); - } -} diff --git a/app/Models/Role.php b/app/Models/Role.php deleted file mode 100644 index 9414739..0000000 --- a/app/Models/Role.php +++ /dev/null @@ -1,34 +0,0 @@ - - */ - protected $fillable = [ - 'organization_id', - 'label', - 'label_translation_key', - ]; - - public function organization(): BelongsTo - { - return $this->belongsTo(Organization::class); - } -} diff --git a/app/Models/User.php b/app/Models/User.php index b06e250..2a74eed 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -4,7 +4,6 @@ use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; @@ -25,15 +24,9 @@ class User extends Authenticatable implements MustVerifyEmail * @var array */ protected $fillable = [ - 'first_name', - 'last_name', - 'organization_id', - 'name_for_avatar', 'email', 'email_verified_at', 'password', - 'permissions', - 'locale', ]; /** @@ -55,9 +48,4 @@ class User extends Authenticatable implements MustVerifyEmail 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; - - public function organization(): BelongsTo - { - return $this->belongsTo(Organization::class); - } } diff --git a/app/Services/CreateAccount.php b/app/Services/CreateAccount.php index 7151a5f..4f0fa90 100644 --- a/app/Services/CreateAccount.php +++ b/app/Services/CreateAccount.php @@ -2,8 +2,6 @@ namespace App\Services; -use App\Jobs\PopulateAccount; -use App\Models\Organization; use App\Models\User; use Illuminate\Support\Facades\Hash; @@ -13,44 +11,25 @@ class CreateAccount extends BaseService { private User $user; - private Organization $organization; public function __construct( public string $email, public string $password, - public string $firstName, - public string $lastName, - public string $organizationName ) { } public function execute(): User { - $this->createOrganization(); $this->createUser(); - PopulateAccount::dispatch($this->organization); - return $this->user; } private function createUser(): void { $this->user = User::create([ - 'first_name' => $this->firstName, - 'last_name' => $this->lastName, 'email' => $this->email, - 'name_for_avatar' => $this->firstName, 'password' => Hash::make($this->password), - 'organization_id' => $this->organization->id, - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - } - - private function createOrganization(): void - { - $this->organization = Organization::create([ - 'name' => $this->organizationName, ]); } } diff --git a/app/Services/CreateLevel.php b/app/Services/CreateLevel.php deleted file mode 100644 index 1be46ea..0000000 --- a/app/Services/CreateLevel.php +++ /dev/null @@ -1,41 +0,0 @@ -checkPermissions(); - $this->create(); - - return $this->level; - } - - private function checkPermissions(): void - { - if (auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function create(): void - { - $this->level = Level::create([ - 'organization_id' => auth()->user()->organization_id, - 'label' => $this->label, - ]); - } -} diff --git a/app/Services/CreateRole.php b/app/Services/CreateRole.php deleted file mode 100644 index 7aec017..0000000 --- a/app/Services/CreateRole.php +++ /dev/null @@ -1,41 +0,0 @@ -checkPermissions(); - $this->create(); - - return $this->role; - } - - private function checkPermissions(): void - { - if (auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function create(): void - { - $this->role = Role::create([ - 'organization_id' => auth()->user()->organization_id, - 'label' => $this->label, - ]); - } -} diff --git a/app/Services/DestroyLevel.php b/app/Services/DestroyLevel.php deleted file mode 100644 index cb77787..0000000 --- a/app/Services/DestroyLevel.php +++ /dev/null @@ -1,44 +0,0 @@ -checkPermissions(); - $this->checkLevel(); - $this->destroy(); - } - - public function destroy(): void - { - $this->level->delete(); - } - - private function checkPermissions(): void - { - if ( - auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR - ) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function checkLevel(): void - { - if ($this->level->organization_id !== auth()->user()->organization_id) { - throw new Exception(__('You do not have permission to do this action.')); - } - } -} diff --git a/app/Services/DestroyRole.php b/app/Services/DestroyRole.php deleted file mode 100644 index 1b4a6b8..0000000 --- a/app/Services/DestroyRole.php +++ /dev/null @@ -1,44 +0,0 @@ -checkPermissions(); - $this->checkRole(); - $this->destroy(); - } - - public function destroy(): void - { - $this->role->delete(); - } - - private function checkPermissions(): void - { - if ( - auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR - ) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function checkRole(): void - { - if ($this->role->organization_id !== auth()->user()->organization_id) { - throw new Exception(__('You do not have permission to do this action.')); - } - } -} diff --git a/app/Services/UpdateLevel.php b/app/Services/UpdateLevel.php deleted file mode 100644 index e50dbd0..0000000 --- a/app/Services/UpdateLevel.php +++ /dev/null @@ -1,49 +0,0 @@ -checkPermissions(); - $this->checkLevel(); - $this->update(); - - return $this->level; - } - - private function checkPermissions(): void - { - if ( - auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR - ) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function checkLevel(): void - { - if ($this->level->organization_id !== auth()->user()->organization_id) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function update(): void - { - $this->level->update([ - 'label' => $this->label, - ]); - } -} diff --git a/app/Services/UpdateRole.php b/app/Services/UpdateRole.php deleted file mode 100644 index e5ce8c7..0000000 --- a/app/Services/UpdateRole.php +++ /dev/null @@ -1,49 +0,0 @@ -checkPermissions(); - $this->checkRole(); - $this->update(); - - return $this->role; - } - - private function checkPermissions(): void - { - if ( - auth()->user()->permissions !== User::ROLE_ACCOUNT_MANAGER && - auth()->user()->permissions !== User::ROLE_ADMINISTRATOR - ) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function checkRole(): void - { - if ($this->role->organization_id !== auth()->user()->organization_id) { - throw new Exception(__('You do not have permission to do this action.')); - } - } - - private function update(): void - { - $this->role->update([ - 'label' => $this->label, - ]); - } -} diff --git a/app/Traits/Translatable.php b/app/Traits/Translatable.php deleted file mode 100644 index 30927bf..0000000 --- a/app/Traits/Translatable.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ - protected function label(): Attribute - { - return Attribute::make( - get: function ($value, $attributes) { - if (! $value) { - return __($attributes['label_translation_key']); - } - - return $value; - } - ); - } -} diff --git a/app/View/Components/LoginLayout.php b/app/View/Components/LoginLayout.php new file mode 100644 index 0000000..e00d706 --- /dev/null +++ b/app/View/Components/LoginLayout.php @@ -0,0 +1,17 @@ +b;=;151o43)vg@+q$4fuf7a9dIK2pby%nBP^T^(5s6?XExF?w+5$tmkL- zb+;$IainJZ)6wB=BxdeWEM=!1dPUy$ zw)I}brr0wAd&(#4F+B~f>t$(!;|LiBy~nBR2Y8Q?OF!mU6$?9GtXH*{KTs@r^;7h! zR(slu5UXhku&i!;2_dPF8+k!O?p9?gA!eYv&}KuPf`1F-0m#Q7e+X%V%r7NmB;?b; zvJ-wtS(CX;&oc>9=5;12Pe95jb>(`Vi(zjCE`gMO@t{BXOpkB9qVkG zUIBrWeK-gyV>kPny+w_y$WMV~7gtZ$?L6&)mWH*yj{B8*Zt3tLbL!J{yW^0OfnP#O z{foLR4koxG$ppRa4IaOz(K}S7Cw~W0lH>8W`C7bd+JiH6M_2f+#9X>K)RQ=W97CZ& zDzoLCRfT-AF^TOMONbBJWKLbGfsEsui>9+fXejau67C+UvOh*q0`E*$SpmjVt|<~x zFAvx?_8D|@p)>H#;VR3YKnNxQyXh#EEd$bh^}~KQ4>&Y>iHGq!iw`+8rM7^OIlM2u zLfM0__57Li3TB>22znii=We6Q9tT24rFX=C7HAew9H+Ue@;=aX{>V|m;xX`;8stUO zRizZDTzaMJd0DYWLp)Hdv3t-;zp!zsw44t?w`meQK$jqO>@6S}D`LU!0ZIF~NFELx z5orllkX18~tXXH}6p*Ykj`y2X_7F(sf*ePv%z;BB`AFpbd8NFpL}M>QBR$1MIQ*1{ zp-aP|niJ8vN2_cJkc@1QRk9sXM0w{Vm0bXecEF_41U@uXqceG#s2Gfa2t6FNUovJVEd9pvJxc?EtnCR^yT=H{fJB$e; z^D?)_ZbBz3!x_W`n0VN&8Rk{;a`$w$1uW?4fC%;*AW1A}8K){1+(EPWG-HLb0$=4a z75XMGo2k*eJb>S$d3dJAHiBbGKlY%B?*K{Kh)jll#RIc6I-iGUY3xJXNV2^+4wT9&9+<6B!NapPHWK%h%pdNuRJIvNy3_eN4m1-86OyIUK^~r?(P}<4M`JtD zS}aOl@>F&mNM2nLM9n;0tE^VWROykO$BaLsd7 z@8o~hRsDwT{?SnPp<%%#`hd&(Tb8kLc@bX~Yj91?+ zXuZB5bRyW~pkIe_j>S=$5X$Ru80a0oC?wb?ATt@^20{-)GYuK@&<6<(gb;7L-`CPX z$k#mQ*xz>>&A46TSvnSm!JvYBdaE;{cX+VD@3XIICq!;b;C;R4l*K5+#QS?Icvt#_ z&>!BuRT#SXc_@#Th^-0KYK#3r8tA&-(NlXN$v{_5u}`(*%=*PG6U~grX?j}xPMXI4 z22QJO3*>A&Qwh__cBj+sbR7^hk-F$9;Yp`8^kZ>UiUDyoky`1XxGMz}&JnbUnniOG z&=~Q25|B&$EeZQ7#X>VgwRn<2EEO*>tZf##8L-?gQj-xo_TtGIJuv1p8y!aMsdhvs zWS?-ufaZ!7QXCMb6lxVePNvzm*lXwQs{NPdlaqtkb;Xzd? zpLZAr#c+xftGl6RMIpS!oUTlv*(I^ZPk(yFVEuyK7b7GTPqr76*z;%EqKmbj;lDl? zO%eB|LmWu~A!Efu>Fq>s#xR;gZLtSXbHQV)y7#PFXrL~=B63>Pq=JZY(U}VS2y>aD zCzWQfi}03>rhCL?EZJhOrM1)cbgjE~LxwCtg)llT;?h9kd9gN))|Bi;&8gUy{Kby1CQ?AsDzosFH@gmQNBsPi)2%8yyuZ?hIJ->_H z+;&Vd=7Krea96ZSJ4I|aqSSoxiIHBWN#f9OAhTGPDGL`y6SbDaoo&X=lJe`V{&6@sQk7-Zs9CI&n9B3$@`iTg{g9{m;u z=&2pI<3W*XL04A`w*?(}QLKQl#U6sL-3^=j_r3Crfxd(bSPsl_u~XXhiC$2+WszH+oL^K~Jt!9M{uC9PC)NE1( znmU2e(a3drV`?K)YaLB9O4bb77PV+BRmT#iNu8-WYR4amsT!@el4#QB?z=mk$@E8m z)OE)L50CoY8&LwoOkd zT-g4b{yG-FZ1*HWk_qYTjmq(pb=)1r=YZ3&?)Uzvnc&~a=z3pN9)z@Dz0vD!E%60N z5c`b4OL>2MmaiIUERYK_1=82l+_K(Fh#i;#H~Cvudi()$pjgMR_?jC_+FOZjnr>eh zm8~WImIhB7Lil}aeQl($L|-p}ADP_|UasVsw%K&;D}GN~o41jexkt%z9xv4^@&;Ph zdl8#pj~RQMWqM3cL(6(u+Pxw|#z6maxvsy;`;|QU89%RNv0=Mj)jRx-l9j)_La%C- zCs2Y|O-q1fb(1OyNri0ZQxoz!;-?cb4(JB7IgrQTKMS%Cay;Z_NGoK~3_>1*d>vSJ zVhyCM$?VkgOoWtq4MpVm@Na+{}|V=u6bz1FwZThh3a>;#rwY?`gxc>=-ahBdyn+pw3prNf8JX;9Pc`XMC)`yi!$ zt1j)GiaU}_r#H~x@p~G*59a8}Ux$?Bc>JxtX7B1i$6Vdf2;Y&IN9#lViBA`$f|yQ< zNSGAD_?@wnd6_YZ^-Lthhm~Yb9jf8GiTt&a+3eS7Dst;2-2Ir!{uV_EyenO0Q!t`( zO_7K;@}Ny)m!Vq-oq>0ysjO%UA(#g2rV~{5ERgPN2=+U8uvDYxco@I4_-Lu7)J!F$ znjcMfDI8zx`Nnh?Ge1rU`rR4N-A0u?2_%z;cf{`knhzAmX`ZT_0-DVqmAY6Qh8~lH zylA?rs6bWHD_zH(c8z|(gLaMGgjV{6jYFkQJ__B2Y48ADg4D4Ofn=>OK(Zno?FYhOMk9Oyq{owt<%2Fgo{ZoJl08n8 z^QRmJni0wIb9~9jk=&UBSAq1W&qW82;7pBWgFtM7y`02FK>8fH5%H%$ z&tOfT(ocbY5b-5@Tc#3H7x5+IcK|&r=aPQPowGIOhLgn+Tg;=OcShvM3_~eN21Ouw z5^j}RAblL#faDsQ4a(0+B+F4!(TBN_fqwyCvMG^4qrE&hM`IVEsE00|;d+mlVKpq9g)eAKkT&($ZEp6>j^qmFu4e*KUAfg7Ly_V%`c#=MN({)V2e})EfcSE^{<0w@^`TeB^dYvy03HBGTnT&8(Lw7>+3>gd22nh{@5O2Wm zYi=XtF3&yuuU_Lg+_Ld39SdV%P{ln13o@ejd1r&)XImX0L~c{~(Sc#59%Y#L(143~ zr%wr8{pd<@={*~RT7>~o2_aS+wwc?PjmY++anio6V1c8kB-_>~8DuBS=4itW(IV~QMUN4s7KsZ+Izki0{xl%7SeGda7e*7cRK}i3e}Ay@@(OcO zMI>Y-nb?Er%P|uyDL*N)|0m4|2jj##6V0L}qQ^x4*ZH+n#$H&N%Cg+r+&4}e=nPvW zW`~gf>v=vP-prss{~m+4#TF20jXest?^>|xuJs_U5Hu~qV3IhViNTJ&4(m2NzNhm1 zp>JV;p4xCb?iHz7=xUR2XQ3lo#Y+&@*rU+V+wj`ZFZwnb=-aq~<-qid?b2>g9LSgo>%}+Ow3s#wOtw%OPk%KqHJ83O5r@RRf=&>J NYG}g1LpOC#_&2gHI2Ql_ diff --git a/composer.json b/composer.json index 59382fd..c01063a 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.10", "laravel/sanctum": "^3.3", + "laravel/scout": "^10.6", "laravel/tinker": "^2.8", "openai-php/laravel": "^0.8.0", "spatie/simple-excel": "^3.2", diff --git a/composer.lock b/composer.lock index 201e1c6..07cc30a 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": "06ce4e6c990507c3e5190d5854fce977", + "content-hash": "7e7ecb6d9d90f24922910363d1815406", "packages": [ { "name": "amirami/localizator", @@ -1422,16 +1422,16 @@ }, { "name": "laravel/framework", - "version": "v10.38.0", + "version": "v10.38.2", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a" + "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/531732a17e4d0fa4fc4fb987a72abbdb93537d3a", - "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a", + "url": "https://api.github.com/repos/laravel/framework/zipball/43da808391da3540d44a8dfeb4e46da4ad8f5723", + "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723", "shasum": "" }, "require": { @@ -1477,6 +1477,8 @@ "voku/portable-ascii": "^2.0" }, "conflict": { + "carbonphp/carbon-doctrine-types": ">=3.0", + "doctrine/dbal": ">=4.0", "tightenco/collect": "<5.5.33" }, "provide": { @@ -1588,6 +1590,7 @@ "files": [ "src/Illuminate/Collections/helpers.php", "src/Illuminate/Events/functions.php", + "src/Illuminate/Filesystem/functions.php", "src/Illuminate/Foundation/helpers.php", "src/Illuminate/Support/helpers.php" ], @@ -1620,7 +1623,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-19T14:59:00+00:00" + "time": "2023-12-22T14:39:10+00:00" }, { "name": "laravel/prompts", @@ -1745,6 +1748,81 @@ }, "time": "2023-11-03T13:42:14+00:00" }, + { + "name": "laravel/scout", + "version": "v10.6.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/scout.git", + "reference": "fc9bc0c2061eb54b31d9dba0999755177a8f1a0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/scout/zipball/fc9bc0c2061eb54b31d9dba0999755177a8f1a0e", + "reference": "fc9bc0c2061eb54b31d9dba0999755177a8f1a0e", + "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", + "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", + "php-http/guzzle7-adapter": "^1.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "algolia/algoliasearch-client-php": "Required to use the Algolia engine (^3.2).", + "meilisearch/meilisearch-php": "Required to use the Meilisearch engine (^1.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "10.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Scout\\ScoutServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Scout\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Scout provides a driver based solution to searching your Eloquent models.", + "keywords": [ + "algolia", + "laravel", + "search" + ], + "support": { + "issues": "https://github.com/laravel/scout/issues", + "source": "https://github.com/laravel/scout" + }, + "time": "2023-12-05T19:44:31+00:00" + }, { "name": "laravel/serializable-closure", "version": "v1.3.3", @@ -2768,16 +2846,16 @@ }, { "name": "openai-php/client", - "version": "v0.8.0", + "version": "v0.8.1", "source": { "type": "git", "url": "https://github.com/openai-php/client.git", - "reference": "d0e4996f6446ced6ad35ec0ea6af20e3596c648f" + "reference": "ce84f541fe8a2869de7f48030d5757be1fd604c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/openai-php/client/zipball/d0e4996f6446ced6ad35ec0ea6af20e3596c648f", - "reference": "d0e4996f6446ced6ad35ec0ea6af20e3596c648f", + "url": "https://api.github.com/repos/openai-php/client/zipball/ce84f541fe8a2869de7f48030d5757be1fd604c9", + "reference": "ce84f541fe8a2869de7f48030d5757be1fd604c9", "shasum": "" }, "require": { @@ -2790,17 +2868,17 @@ "psr/http-message": "^1.1.0|^2.0.0" }, "require-dev": { - "guzzlehttp/guzzle": "^7.8.0", - "guzzlehttp/psr7": "^2.6.1", - "laravel/pint": "^1.13.6", - "mockery/mockery": "^1.6.6", + "guzzlehttp/guzzle": "^7.8.1", + "guzzlehttp/psr7": "^2.6.2", + "laravel/pint": "^1.13.7", + "mockery/mockery": "^1.6.7", "nunomaduro/collision": "^7.10.0", - "pestphp/pest": "^2.25.0", - "pestphp/pest-plugin-arch": "^2.4.1", + "pestphp/pest": "^2.28.1", + "pestphp/pest-plugin-arch": "^2.5", "pestphp/pest-plugin-type-coverage": "^2.5.0", - "phpstan/phpstan": "^1.10.44", + "phpstan/phpstan": "^1.10.50", "rector/rector": "^0.16.0", - "symfony/var-dumper": "^6.3.8" + "symfony/var-dumper": "^6.4" }, "type": "library", "autoload": { @@ -2840,7 +2918,7 @@ ], "support": { "issues": "https://github.com/openai-php/client/issues", - "source": "https://github.com/openai-php/client/tree/v0.8.0" + "source": "https://github.com/openai-php/client/tree/v0.8.1" }, "funding": [ { @@ -2856,7 +2934,7 @@ "type": "github" } ], - "time": "2023-11-23T14:04:47+00:00" + "time": "2023-12-22T15:18:26+00:00" }, { "name": "openai-php/laravel", @@ -9681,23 +9759,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.10", + "version": "10.1.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59" + "reference": "78c3b7625965c2513ee96569a4dbb62601784145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/599109c8ca6bae97b23482d557d2874c25a65e59", - "reference": "599109c8ca6bae97b23482d557d2874c25a65e59", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", + "reference": "78c3b7625965c2513ee96569a4dbb62601784145", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-text-template": "^3.0", @@ -9747,7 +9825,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" }, "funding": [ { @@ -9755,7 +9833,7 @@ "type": "github" } ], - "time": "2023-12-11T06:28:43+00:00" + "time": "2023-12-21T15:38:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -10522,20 +10600,20 @@ }, { "name": "sebastian/complexity", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -10544,7 +10622,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -10568,7 +10646,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -10576,20 +10654,20 @@ "type": "github" } ], - "time": "2023-09-28T11:50:59+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", "shasum": "" }, "require": { @@ -10602,7 +10680,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -10635,7 +10713,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" }, "funding": [ { @@ -10643,7 +10721,7 @@ "type": "github" } ], - "time": "2023-05-01T07:48:21+00:00" + "time": "2023-12-22T10:55:06+00:00" }, { "name": "sebastian/environment", @@ -10851,20 +10929,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -10897,7 +10975,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -10905,7 +10983,7 @@ "type": "github" } ], - "time": "2023-08-31T09:25:50+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", @@ -11471,16 +11549,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "2.3.2", + "version": "2.3.3", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "4800661a195e15783477d99f7f8f669a49793996" + "reference": "66499cd3c858642ded56dafb8fa0352057ca20dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/4800661a195e15783477d99f7f8f669a49793996", - "reference": "4800661a195e15783477d99f7f8f669a49793996", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/66499cd3c858642ded56dafb8fa0352057ca20dd", + "reference": "66499cd3c858642ded56dafb8fa0352057ca20dd", "shasum": "" }, "require": { @@ -11559,7 +11637,7 @@ "type": "github" } ], - "time": "2023-12-15T13:44:49+00:00" + "time": "2023-12-21T09:43:05+00:00" }, { "name": "spatie/laravel-ray", diff --git a/config/scout.php b/config/scout.php new file mode 100644 index 0000000..481d9c3 --- /dev/null +++ b/config/scout.php @@ -0,0 +1,142 @@ + env('SCOUT_DRIVER', 'algolia'), + + /* + |-------------------------------------------------------------------------- + | Index Prefix + |-------------------------------------------------------------------------- + | + | Here you may specify a prefix that will be applied to all search index + | names used by Scout. This prefix may be useful if you have multiple + | "tenants" or applications sharing the same search infrastructure. + | + */ + + 'prefix' => env('SCOUT_PREFIX', ''), + + /* + |-------------------------------------------------------------------------- + | Queue Data Syncing + |-------------------------------------------------------------------------- + | + | This option allows you to control if the operations that sync your data + | with your search engines are queued. When this is set to "true" then + | all automatic data syncing will get queued for better performance. + | + */ + + 'queue' => env('SCOUT_QUEUE', false), + + /* + |-------------------------------------------------------------------------- + | Database Transactions + |-------------------------------------------------------------------------- + | + | This configuration option determines if your data will only be synced + | with your search indexes after every open database transaction has + | been committed, thus preventing any discarded data from syncing. + | + */ + + 'after_commit' => false, + + /* + |-------------------------------------------------------------------------- + | Chunk Sizes + |-------------------------------------------------------------------------- + | + | These options allow you to control the maximum chunk size when you are + | mass importing data into the search engine. This allows you to fine + | tune each of these chunk sizes based on the power of the servers. + | + */ + + 'chunk' => [ + 'searchable' => 500, + 'unsearchable' => 500, + ], + + /* + |-------------------------------------------------------------------------- + | Soft Deletes + |-------------------------------------------------------------------------- + | + | This option allows to control whether to keep soft deleted records in + | the search indexes. Maintaining soft deleted records can be useful + | if your application still needs to search for the records later. + | + */ + + 'soft_delete' => false, + + /* + |-------------------------------------------------------------------------- + | Identify User + |-------------------------------------------------------------------------- + | + | This option allows you to control whether to notify the search engine + | of the user performing the search. This is sometimes useful if the + | engine supports any analytics based on this application's users. + | + | Supported engines: "algolia" + | + */ + + 'identify' => env('SCOUT_IDENTIFY', false), + + /* + |-------------------------------------------------------------------------- + | Algolia Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure your Algolia settings. Algolia is a cloud hosted + | search engine which works great with Scout out of the box. Just plug + | in your application ID and admin API key to get started searching. + | + */ + + 'algolia' => [ + 'id' => env('ALGOLIA_APP_ID', ''), + 'secret' => env('ALGOLIA_SECRET', ''), + ], + + /* + |-------------------------------------------------------------------------- + | Meilisearch Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure your Meilisearch settings. Meilisearch is an open + | source search engine with minimal configuration. Below, you can state + | the host and key information for your own Meilisearch installation. + | + | See: https://www.meilisearch.com/docs/learn/configuration/instance_options#all-instance-options + | + */ + + 'meilisearch' => [ + 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), + 'key' => env('MEILISEARCH_KEY'), + 'index-settings' => [ + // 'users' => [ + // 'filterableAttributes'=> ['id', 'name', 'email'], + // ], + ], + ], + +]; diff --git a/database/factories/LevelFactory.php b/database/factories/LevelFactory.php deleted file mode 100644 index 66f6070..0000000 --- a/database/factories/LevelFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class LevelFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'organization_id' => Organization::factory(), - 'label' => fake()->name, - 'label_translation_key' => fake()->name, - ]; - } -} diff --git a/database/factories/OrganizationFactory.php b/database/factories/OrganizationFactory.php deleted file mode 100644 index ec6dcd5..0000000 --- a/database/factories/OrganizationFactory.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -class OrganizationFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => 'Dunder Mifflin', - ]; - } -} diff --git a/database/factories/RoleFactory.php b/database/factories/RoleFactory.php deleted file mode 100644 index 5ba8e43..0000000 --- a/database/factories/RoleFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class RoleFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'organization_id' => Organization::factory(), - 'label' => fake()->name, - 'label_translation_key' => fake()->name, - ]; - } -} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index f85bc22..4ae6dec 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,8 +2,6 @@ namespace Database\Factories; -use App\Models\Organization; -use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; @@ -23,15 +21,10 @@ class UserFactory extends Factory public function definition(): array { return [ - 'organization_id' => Organization::factory(), - 'first_name' => fake()->name(), - 'last_name' => fake()->name(), - 'name_for_avatar' => fake()->name(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), - 'permissions' => User::ROLE_ADMINISTRATOR, ]; } diff --git a/database/migrations/2014_04_13_002417_create_organizations_table.php b/database/migrations/2014_04_13_002417_create_organizations_table.php deleted file mode 100644 index f832e1b..0000000 --- a/database/migrations/2014_04_13_002417_create_organizations_table.php +++ /dev/null @@ -1,18 +0,0 @@ -id(); - $table->string('name'); - $table->string('licence_key')->nullable(); - $table->timestamps(); - }); - } -}; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 0004cd6..4cf6545 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -13,18 +13,11 @@ public function up(): void { Schema::create('users', function (Blueprint $table): void { $table->id(); - $table->unsignedBigInteger('organization_id'); - $table->string('first_name')->nullable(); - $table->string('last_name')->nullable(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->string('permissions'); - $table->string('name_for_avatar'); - $table->string('locale')->default('en'); $table->rememberToken(); $table->timestamps(); - $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade'); }); } }; diff --git a/database/migrations/2023_11_13_200951_create_roles_table.php b/database/migrations/2023_11_13_200951_create_roles_table.php deleted file mode 100644 index 1046155..0000000 --- a/database/migrations/2023_11_13_200951_create_roles_table.php +++ /dev/null @@ -1,32 +0,0 @@ -id(); - $table->unsignedBigInteger('organization_id'); - $table->string('label')->nullable(); - $table->string('label_translation_key')->nullable(); - $table->timestamps(); - $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade'); - }); - - Schema::create('levels', function (Blueprint $table): void { - $table->id(); - $table->unsignedBigInteger('organization_id'); - $table->string('label')->nullable(); - $table->string('label_translation_key')->nullable(); - $table->timestamps(); - $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade'); - }); - } -}; diff --git a/database/migrations/2023_12_08_013120_create_name_table.php b/database/migrations/2023_12_08_013120_create_name_table.php index 999515a..98104b9 100644 --- a/database/migrations/2023_12_08_013120_create_name_table.php +++ b/database/migrations/2023_12_08_013120_create_name_table.php @@ -24,7 +24,9 @@ public function up(): void $table->text('litterature_artistics_references')->nullable(); $table->text('similar_names_in_other_languages')->nullable(); $table->text('klingon_translation')->nullable(); + $table->integer('syllabes')->default(0); $table->boolean('unisex')->nullable(); + $table->string('characteristics')->nullable(); $table->integer('total')->default(0); $table->integer('page_views')->default(0); $table->timestamps(); diff --git a/database/migrations/2023_12_21_004721_create_characteristics_table.php b/database/migrations/2023_12_21_004721_create_characteristics_table.php new file mode 100644 index 0000000..1212f0c --- /dev/null +++ b/database/migrations/2023_12_21_004721_create_characteristics_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + + Schema::create('characteristic_name', function (Blueprint $table) { + $table->id(); + $table->unsignedBigInteger('characteristic_id'); + $table->unsignedBigInteger('name_id'); + $table->timestamps(); + $table->foreign('characteristic_id')->references('id')->on('characteristics')->onDelete('cascade'); + $table->foreign('name_id')->references('id')->on('names')->onDelete('cascade'); + }); + } +}; diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 64b16f7..7f16287 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,4 +1,4 @@ - + - + diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index b99b545..90193d8 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,49 +1,21 @@ - +
-

{{ __('Welcome to Shelter') }}

-

{{ __('Be part of something unique.') }}

+

Bienvenue

+

Créez un compte pour sauvegarder vos noms préférés et les faire voter par ceux qui vous aiment.

@csrf
- -
-
- - - -
- -
- - - -
-
-
- + - {{ __('We will send you a verification email, and won\'t spam you.') }} + Nous vous enverrons un email de vérification, et ne vous spammerons jamais. @@ -61,7 +33,7 @@
- +
- +
-
- - - - - -
-
- {{ __('Register') }} + {{ __('Créez le compte') }} - {{ __('Already registered?') }} + {{ __('Déjà inscrit ?') }}
- + diff --git a/resources/views/layouts/footer.blade.php b/resources/views/layouts/footer.blade.php new file mode 100644 index 0000000..8af85e0 --- /dev/null +++ b/resources/views/layouts/footer.blade.php @@ -0,0 +1,5 @@ +
+
+ © 2023-{{ now()->year }} +
+
diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index fbe392d..664d57b 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -21,16 +21,8 @@ {{ $slot }}
- -
-
    -
  • - {{ __('English') }} -
  • -
  • - {{ __('French') }} -
  • -
+
+ @include('layouts.footer')
diff --git a/resources/views/layouts/login.blade.php b/resources/views/layouts/login.blade.php new file mode 100644 index 0000000..b1593f9 --- /dev/null +++ b/resources/views/layouts/login.blade.php @@ -0,0 +1,39 @@ + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + @vite(['resources/css/app.css', 'resources/js/app.js']) + + {{ $jsonLdSchema ?? '' }} + + + + + +
+
+ {{ $slot }} +
+ + +
+
    +
  • + {{ __('English') }} +
  • +
  • + {{ __('French') }} +
  • +
+
+
+ + + diff --git a/resources/views/layouts/unlogged-navigation.blade.php b/resources/views/layouts/unlogged-navigation.blade.php index 353eab2..cd0081a 100644 --- a/resources/views/layouts/unlogged-navigation.blade.php +++ b/resources/views/layouts/unlogged-navigation.blade.php @@ -21,6 +21,9 @@ {{ __('Tous les prénoms') }} + + {{ __('Recherche') }} +
diff --git a/resources/views/names/show.blade.php b/resources/views/names/show.blade.php index ab88b2c..1ce61c6 100644 --- a/resources/views/names/show.blade.php +++ b/resources/views/names/show.blade.php @@ -62,8 +62,8 @@ -
-
    +
    +
    - +
    -

    Pays d'origine

    -
    {!! $name['country_of_origin'] !!}
    +

    Nombre de syllabes

    +
    {!! $name['syllabes'] !!}
    @@ -99,7 +99,7 @@

    -
    {!! $name['country_of_origin'] !!}
    +
    {!! $name['syllabes'] !!}
    @@ -177,7 +177,6 @@

    Popularités par décennies

    - @foreach ($popularity['decades'] as $popularityItem) @@ -191,6 +190,7 @@ @endforeach
    Front End Developer Salary
    +

    Utilisé {{ $popularity['total'] }} fois depuis 1900.

    diff --git a/resources/views/search/index.blade.php b/resources/views/search/index.blade.php new file mode 100644 index 0000000..619697b --- /dev/null +++ b/resources/views/search/index.blade.php @@ -0,0 +1,43 @@ + +
    +
    + @include('layouts.unlogged-navigation') +
    + +
    +
    +
      +
    • + Accueil +
    • +
    • Recherche de prénoms
    • +
    +
    +
    +
    + +
    +
    +

    Recherche instantanée

    +
    +
    + + +
    +
    + +

    {{ $stats['total_names'] }} noms | 371 listes de prénoms

    +
    + +
    +
    +

    Les résultats

    + @include('search.partials.results') +
    +
    +
    +
    diff --git a/resources/views/search/partials/results.blade.php b/resources/views/search/partials/results.blade.php new file mode 100644 index 0000000..8ea6deb --- /dev/null +++ b/resources/views/search/partials/results.blade.php @@ -0,0 +1,8 @@ +@forelse ($names['names'] as $name) +
  • +
    {!! $name['avatar'] !!}
    + {{ $name['name'] }} +
  • +@empty +fuck +@endforelse diff --git a/routes/web.php b/routes/web.php index f7b4c19..d50a74d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,15 +6,15 @@ use App\Http\Controllers\MaleNameController; use App\Http\Controllers\NameController; use App\Http\Controllers\ProfileController; +use App\Http\Controllers\SearchController; use App\Http\Controllers\Settings\SettingsController; -use App\Http\Controllers\Settings\SettingsLevelController; -use App\Http\Controllers\Settings\SettingsProfileController; -use App\Http\Controllers\Settings\SettingsRoleController; use Illuminate\Support\Facades\Route; Route::get('locale/{locale}', [LocaleController::class, 'update'])->name('locale.update'); Route::get('', [HomeController::class, 'index'])->name('home.index'); +Route::get('recherche', [SearchController::class, 'index'])->name('search.index'); +Route::post('recherche', [SearchController::class, 'post'])->name('search.post'); Route::get('prenoms', [NameController::class, 'index'])->name('name.index'); Route::get('prenoms/garcons', [MaleNameController::class, 'index'])->name('name.garcon.index'); @@ -43,27 +43,6 @@ // settings Route::get('settings', [SettingsController::class, 'index'])->name('settings.index'); - - Route::middleware(['administrator'])->group(function (): void { - // profile - Route::get('settings/profile', [SettingsProfileController::class, 'index'])->name('settings.profile.index'); - - // roles - Route::get('settings/roles', [SettingsRoleController::class, 'index'])->name('settings.role.index'); - Route::get('settings/roles/new', [SettingsRoleController::class, 'new'])->name('settings.role.new'); - Route::post('settings/roles', [SettingsRoleController::class, 'store'])->name('settings.role.store'); - Route::get('settings/roles/{role}/edit', [SettingsRoleController::class, 'edit'])->name('settings.role.edit'); - Route::put('settings/roles/{role}', [SettingsRoleController::class, 'update'])->name('settings.role.update'); - Route::delete('settings/roles/{role}', [SettingsRoleController::class, 'destroy'])->name('settings.role.destroy'); - - // levels - Route::get('settings/levels', [SettingsLevelController::class, 'index'])->name('settings.level.index'); - Route::get('settings/levels/new', [SettingsLevelController::class, 'new'])->name('settings.level.new'); - Route::post('settings/levels', [SettingsLevelController::class, 'store'])->name('settings.level.store'); - Route::get('settings/levels/{level}/edit', [SettingsLevelController::class, 'edit'])->name('settings.level.edit'); - Route::put('settings/levels/{level}', [SettingsLevelController::class, 'update'])->name('settings.level.update'); - Route::delete('settings/levels/{level}', [SettingsLevelController::class, 'destroy'])->name('settings.level.destroy'); - }); }); require __DIR__ . '/auth.php'; diff --git a/tests/Browser/SettingsRolesAndLevelsTest.php b/tests/Browser/SettingsRolesAndLevelsTest.php deleted file mode 100644 index 4d2e94e..0000000 --- a/tests/Browser/SettingsRolesAndLevelsTest.php +++ /dev/null @@ -1,105 +0,0 @@ -create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - - $this->browse(function (Browser $browser) use ($administrator): void { - // create a new role - $browser->loginAs($administrator) - ->visit('/dashboard') - ->click('@nav-settings-link') - ->click('@manage-role-link') - ->waitFor('@add-role-cta') - ->click('@add-role-cta') - ->assertPathIs('/settings/roles/new') - ->type('label', 'Software developer') - ->waitFor('@submit-form-button') - ->click('@submit-form-button') - ->assertPathIs('/settings/roles') - ->assertSee('Software developer'); - - // edit a role - $role = Role::orderBy('updated_at', 'desc') - ->where('organization_id', $administrator->organization_id) - ->first(); - - $browser->visit('/settings/roles') - ->waitFor('@edit-role-' . $role->id) - ->click('@edit-role-' . $role->id) - ->type('label', 'Awesome developer') - ->waitFor('@submit-form-button') - ->click('@submit-form-button') - ->assertPathIs('/settings/roles') - ->assertSee('Awesome developer'); - - // delete a role - $browser->visit('/settings/roles') - ->waitFor('@delete-role-' . $role->id) - ->click('@delete-role-' . $role->id) - ->acceptDialog() - ->pause(150) - ->assertDontSee('Awesome developer'); - }); - } - - /** @test */ - public function it_lets_you_crud_a_level(): void - { - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - - $this->browse(function (Browser $browser) use ($administrator): void { - // create a level - $browser->loginAs($administrator) - ->visit('/dashboard') - ->click('@nav-settings-link') - ->waitFor('@manage-level-link') - ->click('@manage-level-link') - ->waitFor('@add-level-cta') - ->click('@add-level-cta') - ->type('label', 'Intermediate') - ->waitFor('@submit-form-button') - ->click('@submit-form-button') - ->assertPathIs('/settings/levels') - ->pause(150) - ->assertSee('Intermediate'); - - // edit a level - $level = Level::orderBy('updated_at', 'desc') - ->where('organization_id', $administrator->organization_id) - ->first(); - - $browser->visit('/settings/levels') - ->waitFor('@edit-level-' . $level->id) - ->click('@edit-level-' . $level->id) - ->type('label', 'Intermediate Senior') - ->waitFor('@submit-form-button') - ->click('@submit-form-button') - ->assertPathIs('/settings/levels') - ->assertSee('Intermediate Senior'); - - // delete a level - $browser->visit('/settings/levels') - ->waitFor('@delete-level-' . $level->id) - ->click('@delete-level-' . $level->id) - ->acceptDialog() - ->pause(150) - ->assertDontSee('Intermediate Senior'); - }); - } -} diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 58634e5..9b79da3 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -26,12 +26,9 @@ public function registration_screen_can_be_rendered(): void public function new_users_can_register(): void { $response = $this->post('/register', [ - 'first_name' => 'Test', - 'last_name' => 'User', 'email' => 'test@example.com', 'password' => 'password', 'password_confirmation' => 'password', - 'organization_name' => 'Test Organization', ]); $this->assertAuthenticated(); diff --git a/tests/Feature/Settings/ManageLevelTest.php b/tests/Feature/Settings/ManageLevelTest.php deleted file mode 100644 index 2ebcf31..0000000 --- a/tests/Feature/Settings/ManageLevelTest.php +++ /dev/null @@ -1,104 +0,0 @@ -create([ - 'label' => 'Intermediate', - ]); - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - 'organization_id' => $level->organization_id, - ]); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - 'organization_id' => $level->organization_id, - ]); - - $this->actingAs($user) - ->get('/settings/levels') - ->assertStatus(401); - - $this->actingAs($administrator) - ->get('/settings/levels') - ->assertStatus(200); - - $this->actingAs($administrator) - ->get('/settings/levels') - ->assertSee('Intermediate'); - } - - /** @test */ - public function an_administrator_can_create_a_new_level(): void - { - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - - $this->actingAs($user) - ->post('/settings/levels', [ - 'label' => fake()->name, - ]) - ->assertStatus(401); - - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - - $this->actingAs($administrator) - ->post('/settings/levels', [ - 'label' => 'Advanced', - ]) - ->assertRedirectToRoute('settings.level.index'); - - $this->actingAs($administrator) - ->get('/settings/levels') - ->assertSee('Advanced'); - } - - /** @test */ - public function a_level_can_be_edited(): void - { - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - $level = Level::factory()->create([ - 'organization_id' => $administrator->organization_id, - ]); - - $this->actingAs($administrator) - ->put('/settings/levels/' . $level->id, [ - 'label' => 'Intermediate', - ]) - ->assertStatus(302) - ->assertRedirectToRoute('settings.level.index'); - } - - // /** @test */ - public function a_level_cant_be_edited_with_the_wrong_permission(): void - { - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $level = Level::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - - $this->actingAs($user) - ->put('/settings/levels/' . $level->id, [ - 'label' => 'Intermediate', - ]) - ->assertStatus(401); - } -} diff --git a/tests/Feature/Settings/ManageRoleTest.php b/tests/Feature/Settings/ManageRoleTest.php deleted file mode 100644 index a62e30e..0000000 --- a/tests/Feature/Settings/ManageRoleTest.php +++ /dev/null @@ -1,104 +0,0 @@ -create([ - 'label' => 'Developer', - ]); - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - 'organization_id' => $role->organization_id, - ]); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - 'organization_id' => $role->organization_id, - ]); - - $this->actingAs($user) - ->get('/settings/roles') - ->assertStatus(401); - - $this->actingAs($administrator) - ->get('/settings/roles') - ->assertStatus(200); - - $this->actingAs($administrator) - ->get('/settings/roles') - ->assertSee('Developer'); - } - - /** @test */ - public function an_administrator_can_create_a_new_role(): void - { - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - - $this->actingAs($user) - ->post('/settings/roles', [ - 'label' => fake()->name, - ]) - ->assertStatus(401); - - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - - $this->actingAs($administrator) - ->post('/settings/roles', [ - 'label' => 'Software engineer', - ]) - ->assertRedirectToRoute('settings.role.index'); - - $this->actingAs($administrator) - ->get('/settings/roles') - ->assertSee('Software engineer'); - } - - /** @test */ - public function a_role_can_be_edited(): void - { - $administrator = User::factory()->create([ - 'permissions' => User::ROLE_ADMINISTRATOR, - ]); - $role = Role::factory()->create([ - 'organization_id' => $administrator->organization_id, - ]); - - $this->actingAs($administrator) - ->put('/settings/roles/' . $role->id, [ - 'label' => 'Software engineer', - ]) - ->assertStatus(302) - ->assertRedirectToRoute('settings.role.index'); - } - - // /** @test */ - public function a_role_cant_be_edited_with_the_wrong_permission(): void - { - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $role = Role::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - - $this->actingAs($user) - ->put('/settings/roles/' . $role->id, [ - 'label' => 'Software engineer', - ]) - ->assertStatus(401); - } -} diff --git a/tests/Unit/Jobs/PopulateAccountTest.php b/tests/Unit/Jobs/PopulateAccountTest.php deleted file mode 100644 index 6fccfc7..0000000 --- a/tests/Unit/Jobs/PopulateAccountTest.php +++ /dev/null @@ -1,31 +0,0 @@ -create(); - PopulateAccount::dispatch($organization); - - $this->assertEquals( - 13, - DB::table('roles')->count() - ); - - $this->assertEquals( - 4, - DB::table('levels')->count() - ); - } -} diff --git a/tests/Unit/Models/LevelTest.php b/tests/Unit/Models/LevelTest.php deleted file mode 100644 index c788cea..0000000 --- a/tests/Unit/Models/LevelTest.php +++ /dev/null @@ -1,19 +0,0 @@ -create(); - $this->assertTrue($level->organization()->exists()); - } -} diff --git a/tests/Unit/Models/OrganizationTest.php b/tests/Unit/Models/OrganizationTest.php deleted file mode 100644 index 060c340..0000000 --- a/tests/Unit/Models/OrganizationTest.php +++ /dev/null @@ -1,32 +0,0 @@ -create(); - Role::factory()->create(['organization_id' => $organization->id]); - - $this->assertTrue($organization->roles()->exists()); - } - - /** @test */ - public function it_has_many_levels(): void - { - $organization = Organization::factory()->create(); - Level::factory()->create(['organization_id' => $organization->id]); - - $this->assertTrue($organization->levels()->exists()); - } -} diff --git a/tests/Unit/Models/RoleTest.php b/tests/Unit/Models/RoleTest.php deleted file mode 100644 index 13cbb33..0000000 --- a/tests/Unit/Models/RoleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -create(); - $this->assertTrue($role->organization()->exists()); - } -} diff --git a/tests/Unit/Models/UserTest.php b/tests/Unit/Models/UserTest.php deleted file mode 100644 index 5fa2fe7..0000000 --- a/tests/Unit/Models/UserTest.php +++ /dev/null @@ -1,24 +0,0 @@ -create(); - $user = User::factory()->create([ - 'organization_id' => $organization->id, - ]); - - $this->assertTrue($user->organization()->exists()); - } -} diff --git a/tests/Unit/Services/CreateAccountTest.php b/tests/Unit/Services/CreateAccountTest.php index 9a6a75b..cb1c6fc 100644 --- a/tests/Unit/Services/CreateAccountTest.php +++ b/tests/Unit/Services/CreateAccountTest.php @@ -2,11 +2,9 @@ namespace Tests\Unit\Services; -use App\Jobs\PopulateAccount; use App\Models\User; use App\Services\CreateAccount; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Support\Facades\Queue; use Tests\TestCase; class CreateAccountTest extends TestCase @@ -21,14 +19,9 @@ public function it_creates_an_account(): void private function executeService(): void { - Queue::fake(); - $user = (new CreateAccount( email: 'john@email.com', password: 'johnny', - firstName: 'johnny', - lastName: 'depp', - organizationName: 'johnny inc', ))->execute(); $this->assertInstanceOf( @@ -38,19 +31,7 @@ private function executeService(): void $this->assertDatabaseHas('users', [ 'id' => $user->id, - 'first_name' => 'johnny', - 'last_name' => 'depp', - 'name_for_avatar' => 'johnny', 'email' => 'john@email.com', - 'organization_id' => $user->organization_id, - 'permissions' => 'administrator', - ]); - - $this->assertDatabaseHas('organizations', [ - 'id' => $user->organization_id, - 'name' => 'johnny inc', ]); - - Queue::assertPushed(PopulateAccount::class); } } diff --git a/tests/Unit/Services/CreateLevelTest.php b/tests/Unit/Services/CreateLevelTest.php deleted file mode 100644 index e7f7bf1..0000000 --- a/tests/Unit/Services/CreateLevelTest.php +++ /dev/null @@ -1,51 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $this->executeService($user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $this->executeService($user); - } - - private function executeService(User $user): void - { - $this->actingAs($user); - $level = (new CreateLevel('intermediate'))->execute(); - - $this->assertInstanceOf( - Level::class, - $level - ); - - $this->assertDatabaseHas('levels', [ - 'id' => $level->id, - 'organization_id' => $user->organization_id, - 'label' => 'intermediate', - ]); - } -} diff --git a/tests/Unit/Services/CreateRoleTest.php b/tests/Unit/Services/CreateRoleTest.php deleted file mode 100644 index bc8c778..0000000 --- a/tests/Unit/Services/CreateRoleTest.php +++ /dev/null @@ -1,51 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $this->executeService($user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $this->executeService($user); - } - - private function executeService(User $user): void - { - $this->actingAs($user); - $role = (new CreateRole('developer'))->execute(); - - $this->assertInstanceOf( - Role::class, - $role - ); - - $this->assertDatabaseHas('roles', [ - 'id' => $role->id, - 'organization_id' => $user->organization_id, - 'label' => 'developer', - ]); - } -} diff --git a/tests/Unit/Services/DestroyLevelTest.php b/tests/Unit/Services/DestroyLevelTest.php deleted file mode 100644 index ca4548d..0000000 --- a/tests/Unit/Services/DestroyLevelTest.php +++ /dev/null @@ -1,63 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $level = Level::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($level, $user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $level = Level::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($level, $user); - } - - /** @test */ - public function it_fails_if_the_level_doesnt_belong_to_organization(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $level = Level::factory()->create(); - $this->executeService($level, $user); - } - - private function executeService(Level $level, User $user): void - { - $this->actingAs($user); - (new DestroyLevel( - level: $level, - ))->execute(); - - $this->assertDatabaseMissing('levels', [ - 'id' => $level->id, - ]); - } -} diff --git a/tests/Unit/Services/DestroyRoleTest.php b/tests/Unit/Services/DestroyRoleTest.php deleted file mode 100644 index 437d400..0000000 --- a/tests/Unit/Services/DestroyRoleTest.php +++ /dev/null @@ -1,63 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $role = Role::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($role, $user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $role = Role::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($role, $user); - } - - /** @test */ - public function it_fails_if_the_role_doesnt_belong_to_organization(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $role = Role::factory()->create(); - $this->executeService($role, $user); - } - - private function executeService(Role $role, User $user): void - { - $this->actingAs($user); - (new DestroyRole( - role: $role, - ))->execute(); - - $this->assertDatabaseMissing('roles', [ - 'id' => $role->id, - ]); - } -} diff --git a/tests/Unit/Services/UpdateLevelTest.php b/tests/Unit/Services/UpdateLevelTest.php deleted file mode 100644 index 91521c7..0000000 --- a/tests/Unit/Services/UpdateLevelTest.php +++ /dev/null @@ -1,71 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $level = Level::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($level, $user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $level = Level::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($level, $user); - } - - /** @test */ - public function it_fails_if_the_level_doesnt_belong_to_organization(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $level = Level::factory()->create(); - $this->executeService($level, $user); - } - - private function executeService(Level $level, User $user): void - { - $this->actingAs($user); - $level = (new UpdateLevel( - level: $level, - label: 'developer' - ))->execute(); - - $this->assertInstanceOf( - Level::class, - $level - ); - - $this->assertDatabaseHas('levels', [ - 'id' => $level->id, - 'organization_id' => $user->organization_id, - 'label' => 'developer', - ]); - } -} diff --git a/tests/Unit/Services/UpdateRoleTest.php b/tests/Unit/Services/UpdateRoleTest.php deleted file mode 100644 index 2e52d8d..0000000 --- a/tests/Unit/Services/UpdateRoleTest.php +++ /dev/null @@ -1,71 +0,0 @@ -create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $role = Role::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($role, $user); - } - - /** @test */ - public function it_fails_if_the_user_doesnt_have_the_right_permissions(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_USER, - ]); - $role = Role::factory()->create([ - 'organization_id' => $user->organization_id, - ]); - $this->executeService($role, $user); - } - - /** @test */ - public function it_fails_if_the_role_doesnt_belong_to_organization(): void - { - $this->expectException(Exception::class); - $user = User::factory()->create([ - 'permissions' => User::ROLE_ACCOUNT_MANAGER, - ]); - $role = Role::factory()->create(); - $this->executeService($role, $user); - } - - private function executeService(Role $role, User $user): void - { - $this->actingAs($user); - $role = (new UpdateRole( - role: $role, - label: 'developer' - ))->execute(); - - $this->assertInstanceOf( - Role::class, - $role - ); - - $this->assertDatabaseHas('roles', [ - 'id' => $role->id, - 'organization_id' => $user->organization_id, - 'label' => 'developer', - ]); - } -} diff --git a/tests/Unit/Traits/TranslatableTest.php b/tests/Unit/Traits/TranslatableTest.php deleted file mode 100644 index dad9f84..0000000 --- a/tests/Unit/Traits/TranslatableTest.php +++ /dev/null @@ -1,36 +0,0 @@ -create([ - 'label' => 'this is the real name', - 'label_translation_key' => 'role.label', - ]); - - $this->assertEquals( - 'this is the real name', - $role->label - ); - - $role = Role::factory()->create([ - 'label' => null, - 'label_translation_key' => 'role.label', - ]); - - $this->assertEquals( - 'role.label', - $role->label - ); - } -} diff --git a/tests/Unit/ViewModels/Names/AllNamesViewModelTest.php b/tests/Unit/ViewModels/Names/AllNamesViewModelTest.php index f9802e3..98926fb 100644 --- a/tests/Unit/ViewModels/Names/AllNamesViewModelTest.php +++ b/tests/Unit/ViewModels/Names/AllNamesViewModelTest.php @@ -1,6 +1,6 @@ 'HÉLOÏSE', 'origins' => 'Origine du prénom Héloïse', 'personality' => 'Personnalité du prénom Héloïse', - 'country_of_origin' => 'Pays d\'origine du prénom Héloïse', + 'syllabes' => 2, 'celebrities' => 'Célébrités du prénom Héloïse', 'elfic_traits' => 'Traits elfiques du prénom Héloïse', 'name_day' => 'Fête du prénom Héloïse', @@ -37,7 +37,7 @@ public function it_gets_the_details_of_a_name(): void $this->assertArrayHasKey('avatar', $array); $this->assertArrayHasKey('origins', $array); $this->assertArrayHasKey('personality', $array); - $this->assertArrayHasKey('country_of_origin', $array); + $this->assertArrayHasKey('syllabes', $array); $this->assertArrayHasKey('celebrities', $array); $this->assertArrayHasKey('elfic_traits', $array); $this->assertArrayHasKey('name_day', $array); @@ -80,8 +80,9 @@ public function it_gets_the_stats_per_decade(): void $array = NameViewModel::popularity($name); - $this->assertCount(1, $array); + $this->assertCount(2, $array); $this->assertArrayHasKey('decades', $array); + $this->assertArrayHasKey('total', $array); $this->assertEquals( [ 0 => [ diff --git a/tests/Unit/ViewModels/Settings/SettingsLevelViewModelTest.php b/tests/Unit/ViewModels/Settings/SettingsLevelViewModelTest.php deleted file mode 100644 index 65f3410..0000000 --- a/tests/Unit/ViewModels/Settings/SettingsLevelViewModelTest.php +++ /dev/null @@ -1,44 +0,0 @@ -create(); - $this->actingAs($user); - - $array = SettingsLevelViewModel::index(); - - $this->assertCount(1, $array); - $this->assertArrayHasKey('levels', $array); - } - - /** @test */ - public function it_gets_the_level_object(): void - { - $level = Level::factory()->create([ - 'label' => 'Dunder', - ]); - $array = SettingsLevelViewModel::level($level); - - $this->assertCount(2, $array); - $this->assertEquals( - [ - 'id' => $level->id, - 'label' => 'Dunder', - ], - $array - ); - } -} diff --git a/tests/Unit/ViewModels/Settings/SettingsRoleViewModelTest.php b/tests/Unit/ViewModels/Settings/SettingsRoleViewModelTest.php deleted file mode 100644 index a42b4a2..0000000 --- a/tests/Unit/ViewModels/Settings/SettingsRoleViewModelTest.php +++ /dev/null @@ -1,44 +0,0 @@ -create(); - $this->actingAs($user); - - $array = SettingsRoleViewModel::index(); - - $this->assertCount(1, $array); - $this->assertArrayHasKey('roles', $array); - } - - /** @test */ - public function it_gets_the_role_object(): void - { - $role = Role::factory()->create([ - 'label' => 'Dunder', - ]); - $array = SettingsRoleViewModel::role($role); - - $this->assertCount(2, $array); - $this->assertEquals( - [ - 'id' => $role->id, - 'label' => 'Dunder', - ], - $array - ); - } -}