diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 6884919b..31b4735f 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -30,7 +30,7 @@ public function create(array $input): User ])->validate(); return User::create([ - 'name' => $input['username'], + 'name' => $input['first_name'].' '.$input['last_name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), diff --git a/app/Http/Controllers/API/Auth/RegisterController.php b/app/Http/Controllers/API/Auth/RegisterController.php index 0e2aa5da..ab583f13 100644 --- a/app/Http/Controllers/API/Auth/RegisterController.php +++ b/app/Http/Controllers/API/Auth/RegisterController.php @@ -25,7 +25,7 @@ public function register(Request $request): JsonResponse 'last_name' => $validatedData['last_name'], 'email' => $validatedData['email'], 'username' => $validatedData['username'], - 'name' => $validatedData['username'], + 'name' => $validatedData['first_name']. ' ' . $validatedData['last_name'], 'orcid_id' => $request['orcid_id'], 'affiliation' => $request['affiliation'], 'password' => Hash::make($validatedData['password']), 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 8743d0c6..cabfc71e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -13,13 +13,8 @@ public function up(): void { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name')->nullable(); + $table->string('name'); $table->string('email')->unique(); - $table->string('username')->unique(); - $table->string('first_name'); - $table->string('last_name'); - $table->string('orcid_id')->nullable(); - $table->string('affiliation')->nullable(); $table->timestamp('email_verified_at')->nullable(); $table->string('password')->nullable(); $table->rememberToken(); diff --git a/database/migrations/2024_08_08_150749_add_columns_to_users_table.php b/database/migrations/2024_08_08_150749_add_columns_to_users_table.php new file mode 100644 index 00000000..d7200885 --- /dev/null +++ b/database/migrations/2024_08_08_150749_add_columns_to_users_table.php @@ -0,0 +1,33 @@ +string('name')->nullable()->change(); + $table->string('username')->unique()->nullable(); + $table->string('first_name')->nullable(); + $table->string('last_name')->nullable(); + $table->string('orcid_id')->nullable(); + $table->string('affiliation')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['username', 'first_name', 'last_name', 'orcid_id', 'affiliation']); + }); + } +};