Skip to content

Commit

Permalink
feat: add gender for lists (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss authored Feb 19, 2024
1 parent 7014546 commit d22fb35
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Http/Controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function store(Request $request): RedirectResponse
description: $request->input('description'),
isPublic: false,
canBeModified: true,
gender: $request->input('gender'),
))->execute();

Cache::forget('route-list-' . $list->id);
Expand Down
1 change: 1 addition & 0 deletions app/Models/NameList.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NameList extends Model
'is_public',
'can_be_modified',
'is_list_of_favorites',
'gender',
];

protected $casts = [
Expand Down
2 changes: 2 additions & 0 deletions app/Services/CreateList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public ?string $description,
public bool $isPublic,
public bool $canBeModified,
public string $gender,
) {
}

Expand All @@ -33,6 +34,7 @@ private function createList(): void
'description' => $this->description,
'is_public' => $this->isPublic,
'can_be_modified' => $this->canBeModified,
'gender' => $this->gender,
]);
}
}
1 change: 1 addition & 0 deletions database/factories/NameListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function definition(): array
'can_be_modified' => fake()->boolean,
'is_list_of_favorites' => fake()->boolean,
'uuid' => fake()->uuid,
'gender' => fake()->text(20),
];
}
}
15 changes: 15 additions & 0 deletions database/migrations/2024_02_19_125208_update_user_list_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('lists', function (Blueprint $table) {
$table->string('gender')->after('is_list_of_favorites')->nullable();
});
}
};
36 changes: 35 additions & 1 deletion resources/views/user/lists/new.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>

<!-- description -->
<div class="relative px-6 pt-4 pb-6">
<div class="relative px-6 pt-4 pb-2">
<x-input-label for="description"
:optional="true"
:value="'Description (optionnel)'" />
Expand All @@ -56,6 +56,40 @@
<x-input-error class="mt-2" :messages="$errors->get('description')" />
</div>

<!-- is public -->
<div class="relative px-6 pt-4 pb-4">
<p class="block font-medium text-sm text-gray-700 dark:text-gray-300">{{ __('Genre de la liste') }}</p>
<div class="grid grid-flow-row sm:grid-flow-col sm:grid-cols-3 gap-4 pt-2 pb-4">
<div class="flex p-3 ps-4 border border-gray-200 rounded dark:border-gray-700">
<div class="flex items-center h-5">
<input id="gender-boy" name="gender" checked type="radio" value="male" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
</div>
<div class="ms-2 text-sm">
<label for="gender-boy" class="font-medium text-gray-900 dark:text-gray-300">{{ __('Garçons') }}</label>
<p class="text-xs font-normal text-gray-500 dark:text-gray-300">{{ __('La liste contient des prénoms de garçons.') }}</p>
</div>
</div>
<div class="flex p-3 ps-4 border border-gray-200 rounded dark:border-gray-700">
<div class="flex items-center h-5">
<input id="gender-girl" name="gender" type="radio" value="female" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
</div>
<div class="ms-2 text-sm">
<label for="gender-girl" class="font-medium text-gray-900 dark:text-gray-300">{{ __('Filles') }}</label>
<p class="text-xs font-normal text-gray-500 dark:text-gray-300">{{ __('La liste contient des prénoms de filles.') }}</p>
</div>
</div>
<div class="flex p-3 ps-4 border border-gray-200 rounded dark:border-gray-700">
<div class="flex items-center h-5">
<input id="gender-mixte" name="gender" type="radio" value="unisex" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
</div>
<div class="ms-2 text-sm">
<label for="gender-mixte" class="font-medium text-gray-900 dark:text-gray-300">{{ __('Mixtes') }}</label>
<p class="text-xs font-normal text-gray-500 dark:text-gray-300">{{ __('La liste contient des prénoms mixtes.') }}</p>
</div>
</div>
</div>
</div>

<!-- actions -->
<div class="flex items-center justify-between border-t dark:border-gray-600 bg-white dark:bg-gray-800 px-6 py-4">
<x-link href="{{ route('list.index') }}">{{ __('Back') }}</x-link>
Expand Down

0 comments on commit d22fb35

Please sign in to comment.