From fa64091300aa7f6f6e519931bcaf37242f39a92e Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Thu, 18 Sep 2025 13:43:38 +0330 Subject: [PATCH] feat: add fname & lname --- app/Http/Controllers/UserController.php | 8 +++-- ...add_first_and_last_name_to_users_table.php | 29 +++++++++++++++++++ ...0105_drop_name_column_from_users_table.php | 28 ++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_09_18_095001_add_first_and_last_name_to_users_table.php create mode 100644 database/migrations/2025_09_18_100105_drop_name_column_from_users_table.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9130f07..57702d5 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -60,12 +60,16 @@ public function loginV2(Request $request) 'email' => $response['email'], 'identifier' => $response['uuid'] ?? null, 'password' => config('app.default_password'), - 'name' => trim(($response['first_name'] ?? '') . ' ' . ($response['last_name'] ?? '')), + // 'name' => trim(($response['first_name'] ?? '') . ' ' . ($response['last_name'] ?? '')), 'mobile' => $mobile, + 'first_name' => $response['first_name'] ?? null, + 'last_name' => $response['last_name'] ?? null ]); } else { // Only update name and mobile for existing user - $user->name = trim(($response['first_name'] ?? '') . ' ' . ($response['last_name'] ?? '')); + $user->first_name = $response['first_name'] ?? $user->first_name; + $user->last_name = $response['last_name'] ?? $user->last_name; + // $user->name = trim(($response['first_name'] ?? '') . ' ' . ($response['last_name'] ?? '')); $user->mobile = $mobile ?? $user->mobile; $user->save(); } diff --git a/database/migrations/2025_09_18_095001_add_first_and_last_name_to_users_table.php b/database/migrations/2025_09_18_095001_add_first_and_last_name_to_users_table.php new file mode 100644 index 0000000..fffb178 --- /dev/null +++ b/database/migrations/2025_09_18_095001_add_first_and_last_name_to_users_table.php @@ -0,0 +1,29 @@ +string('first_name')->nullable()->after('id'); + $table->string('last_name')->nullable()->after('first_name'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['first_name', 'last_name']); + }); + } +}; diff --git a/database/migrations/2025_09_18_100105_drop_name_column_from_users_table.php b/database/migrations/2025_09_18_100105_drop_name_column_from_users_table.php new file mode 100644 index 0000000..e93d206 --- /dev/null +++ b/database/migrations/2025_09_18_100105_drop_name_column_from_users_table.php @@ -0,0 +1,28 @@ +dropColumn('name'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->string('name')->nullable(); + }); + } +};