hsntngr
176
13
Laravel

User fields seem empty when the user is has been registered

Posted 8 months ago by hsntngr

I added couple new columns to users table like role, suspended_at and banned_at. And then added them as fillable.

But when new user registered, fields seems empty (except id,created_at and updated_at).

Here is migration file

Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string("username", 20)->unique()->index();
        $table->string('email')->unique();
        $table->string('password');
        $table->string("role",15)->default("newbie");
        $table->rememberToken();
        $table->timestamps();
        $table->dateTime("suspended_at")->nullable();
        $table->dateTime("banned_at")->nullable();
    });

User model

protected $fillable = [
        'name', 'email', 'password', "username", "role", "suspended_at", "banned_at"
    ];

**a small demo from users table. **

+----+------+----------+-------+----------+------+
| id | name | username | email | password | role |
+----+------+----------+-------+----------+------+
|  4 |      |          |       |          | newbie    | 
+----+------+----------+-------+----------+------+

RegisterController

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        "username" => $data["username"],
        'password' => Hash::make($data['password'])
    ]);
}

Please sign in or create an account to participate in this conversation.