Skip to content

Commit

Permalink
fix: added a new migration for new columns of user and filling name w…
Browse files Browse the repository at this point in the history
…ith first and last names
  • Loading branch information
sriramkanakam87 committed Aug 8, 2024
1 parent 68c7979 commit 1fcf7eb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/API/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
7 changes: 1 addition & 6 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->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']);
});
}
};

0 comments on commit 1fcf7eb

Please sign in to comment.