From 76cfd9fee68e450c164ac89439b7836183acd640 Mon Sep 17 00:00:00 2001 From: DoarMihai Date: Sat, 4 Oct 2025 18:52:44 +0300 Subject: [PATCH] started on the 2 step register process --- .../Auth/RegisteredUserController.php | 19 ++ app/Models/User.php | 14 ++ ..._fitness_profile_fields_to_users_table.php | 41 +++ lang/en/app.php | 47 ++++ lang/ro/app.php | 47 ++++ resources/views/auth/register.blade.php | 237 +++++++++++++++--- 6 files changed, 366 insertions(+), 39 deletions(-) create mode 100644 database/migrations/2025_10_04_120000_add_fitness_profile_fields_to_users_table.php diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index 0739e2e..845c0b2 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -33,12 +33,31 @@ class RegisteredUserController extends Controller 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class], 'password' => ['required', 'confirmed', Rules\Password::defaults()], + // Fitness profile (all optional to avoid breaking tests unless specified) + 'age' => ['nullable', 'integer', 'min:5', 'max:120'], + 'weight_kg' => ['nullable', 'numeric', 'min:20', 'max:400'], + 'height_cm' => ['nullable', 'numeric', 'min:80', 'max:250'], + 'fitness_level' => ['nullable', 'in:beginner,intermediate,advanced'], + 'goal' => ['nullable', 'string', 'max:50'], + 'health_notes' => ['nullable', 'string', 'max:65535'], + 'available_equipment' => ['nullable', 'string', 'max:65535'], + 'days_per_week' => ['nullable', 'integer', 'min:1', 'max:7'], + 'minutes_per_session' => ['nullable', 'integer', 'min:5', 'max:600'], ]); $user = User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->password), + 'age' => $request->age, + 'weight_kg' => $request->weight_kg, + 'height_cm' => $request->height_cm, + 'fitness_level' => $request->fitness_level, + 'goal' => $request->goal, + 'health_notes' => $request->health_notes, + 'available_equipment' => $request->available_equipment, + 'days_per_week' => $request->days_per_week, + 'minutes_per_session' => $request->minutes_per_session, ]); event(new Registered($user)); diff --git a/app/Models/User.php b/app/Models/User.php index 072caa3..721c610 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -21,6 +21,15 @@ class User extends Authenticatable 'name', 'email', 'password', + 'age', + 'weight_kg', + 'height_cm', + 'fitness_level', + 'goal', + 'health_notes', + 'available_equipment', + 'days_per_week', + 'minutes_per_session', ]; /** @@ -43,6 +52,11 @@ class User extends Authenticatable return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', + 'age' => 'integer', + 'weight_kg' => 'decimal:2', + 'height_cm' => 'decimal:2', + 'days_per_week' => 'integer', + 'minutes_per_session' => 'integer', ]; } diff --git a/database/migrations/2025_10_04_120000_add_fitness_profile_fields_to_users_table.php b/database/migrations/2025_10_04_120000_add_fitness_profile_fields_to_users_table.php new file mode 100644 index 0000000..28a2e42 --- /dev/null +++ b/database/migrations/2025_10_04_120000_add_fitness_profile_fields_to_users_table.php @@ -0,0 +1,41 @@ +unsignedTinyInteger('age')->nullable()->after('email_verified_at'); + $table->decimal('weight_kg', 5, 2)->nullable()->after('age'); + $table->decimal('height_cm', 5, 2)->nullable()->after('weight_kg'); + $table->string('fitness_level', 20)->nullable()->after('height_cm'); // beginner, intermediate, advanced + $table->string('goal', 50)->nullable()->after('fitness_level'); // strength, endurance, weight_loss, hypertrophy, mobility, etc + $table->text('health_notes')->nullable()->after('goal'); // health conditions / injuries + $table->text('available_equipment')->nullable()->after('health_notes'); + $table->unsignedTinyInteger('days_per_week')->nullable()->after('available_equipment'); + $table->unsignedSmallInteger('minutes_per_session')->nullable()->after('days_per_week'); + $table->index(['fitness_level', 'goal']); + }); + } + + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropIndex(['fitness_level', 'goal']); + $table->dropColumn([ + 'age', + 'weight_kg', + 'height_cm', + 'fitness_level', + 'goal', + 'health_notes', + 'available_equipment', + 'days_per_week', + 'minutes_per_session', + ]); + }); + } +}; diff --git a/lang/en/app.php b/lang/en/app.php index e05ebc5..4aa1d0a 100644 --- a/lang/en/app.php +++ b/lang/en/app.php @@ -161,4 +161,51 @@ return [ 'similar' => 'Similar poses', 'similar_none' => 'No similar poses found.', ], + + 'auth' => [ + 'register' => [ + 'age' => 'Age', + 'weight_kg' => 'Weight (kg)', + 'height_cm' => 'Height (cm)', + 'fitness_level' => 'Fitness level', + 'goal' => 'Primary goal', + 'health_notes' => 'Health conditions or injuries', + 'available_equipment' => 'Available equipment', + 'available_equipment_ph' => 'e.g. dumbbells, barbell, kettlebell, bands, pull-up bar', + 'days_per_week' => 'Days per week', + 'minutes_per_session' => 'Minutes per session', + 'select_optional' => 'Select (optional)', + 'levels' => [ + 'beginner' => 'Beginner', + 'intermediate' => 'Intermediate', + 'advanced' => 'Advanced', + ], + 'goals' => [ + 'strength' => 'Strength', + 'endurance' => 'Endurance', + 'weight_loss' => 'Weight loss', + 'hypertrophy' => 'Hypertrophy', + 'mobility' => 'Mobility', + ], + 'steps' => [ + 'step1_title' => 'Create your account', + 'step2_title' => 'Tell us about your fitness profile (optional)', + 'next' => 'Next', + 'back' => 'Back', + 'register' => 'Register', + ], + 'equipment_options' => [ + 'dumbbells' => 'Dumbbells', + 'barbell' => 'Barbell', + 'kettlebell' => 'Kettlebell', + 'bands' => 'Resistance bands', + 'pullup_bar' => 'Pull-up bar', + 'bench' => 'Bench', + 'machines' => 'Gym machines', + 'yoga_mat' => 'Yoga mat', + 'treadmill' => 'Treadmill', + 'bodyweight' => 'Bodyweight only', + ], + ], + ], ]; diff --git a/lang/ro/app.php b/lang/ro/app.php index f5240ce..f5aa41b 100644 --- a/lang/ro/app.php +++ b/lang/ro/app.php @@ -161,4 +161,51 @@ return [ 'similar' => 'Poziții similare', 'similar_none' => 'Nu s-au găsit poziții similare.', ], + + 'auth' => [ + 'register' => [ + 'age' => 'Vârstă', + 'weight_kg' => 'Greutate (kg)', + 'height_cm' => 'Înălțime (cm)', + 'fitness_level' => 'Nivel de fitness', + 'goal' => 'Obiectiv principal', + 'health_notes' => 'Afectiuni de sănătate sau accidentări', + 'available_equipment' => 'Echipament disponibil', + 'available_equipment_ph' => 'ex: gantere, bară, kettlebell, benzi, bară de tracțiuni', + 'days_per_week' => 'Zile pe săptămână', + 'minutes_per_session' => 'Minute pe sesiune', + 'select_optional' => 'Selectează (opțional)', + 'levels' => [ + 'beginner' => 'Începător', + 'intermediate' => 'Intermediar', + 'advanced' => 'Avansat', + ], + 'goals' => [ + 'strength' => 'Forță', + 'endurance' => 'Anduranță', + 'weight_loss' => 'Scădere în greutate', + 'hypertrophy' => 'Hipertrofie', + 'mobility' => 'Mobilitate', + ], + 'steps' => [ + 'step1_title' => 'Creează-ți contul', + 'step2_title' => 'Spune-ne despre profilul tău de fitness (opțional)', + 'next' => 'Înainte', + 'back' => 'Înapoi', + 'register' => 'Înregistrare', + ], + 'equipment_options' => [ + 'dumbbells' => 'Gantere', + 'barbell' => 'Bară', + 'kettlebell' => 'Kettlebell', + 'bands' => 'Benzi elastice', + 'pullup_bar' => 'Bară de tracțiuni', + 'bench' => 'Bancă', + 'machines' => 'Aparate', + 'yoga_mat' => 'Saltea de yoga', + 'treadmill' => 'Banda de alergare', + 'bodyweight' => 'Doar greutatea corpului', + ], + ], + ], ]; diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index d4b3d58..8a87a92 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,52 +1,211 @@ -
+ @csrf - -
- - - + +
+
+
1
+
{{ __('app.auth.register.steps.step1_title') }}
+
+
+
+
2
+
{{ __('app.auth.register.steps.step2_title') }}
+
- -
- - - + +
+ +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ +
+ + {{ __('Already registered?') }} + + +
- -
- + +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
- + +
+ + + @php + $equipmentOptions = [ + // Simple, high-contrast stroke-based icons to ensure visibility + ['key' => 'dumbbells', 'icon' => ''], + ['key' => 'barbell', 'icon' => ''], + ['key' => 'kettlebell', 'icon' => ''], + ['key' => 'bands', 'icon' => ''], + ['key' => 'pullup_bar', 'icon' => ''], + ['key' => 'bench', 'icon' => ''], + ['key' => 'machines', 'icon' => ''], + ['key' => 'yoga_mat', 'icon' => ''], + ['key' => 'treadmill', 'icon' => ''], + ['key' => 'bodyweight', 'icon' => ''], + ]; + $oldEquip = collect(explode(',', (string) old('available_equipment')))->map(fn($s)=>trim($s))->filter()->values()->all(); + @endphp +
+ @foreach($equipmentOptions as $opt) + @php $selected = in_array($opt['key'], $oldEquip, true); @endphp + + @endforeach +
+

{{ __('app.auth.register.available_equipment_ph') }}

+ +
- +
+ + + +
+
+ + + +
+
+ +
+ + + {{ __('app.auth.register.steps.register') }} + +
- -
- - - - - -
- -
- - {{ __('Already registered?') }} - - - - {{ __('Register') }} - -
+