teguh_rijanandi's avatar

How To edit insert into users value???

Please Guys, help me for edit this default command?? i am want add some code again like a school name, or address SQLSTATE[HY000]: General error: 1364 Field 'sektor' doesn't have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (Teguh Rijanandi, teguhrijanandi02@gmail.com, $2y$10$hqzIZLq3PEK/ndiS7dCDluunnuTUKqEC9hrKBafVwOXkYjdHqF06O, 2018-06-06 15:15:36, 2018-06-06 15:15:36))

0 likes
18 replies
teguh_rijanandi's avatar

i want edited like this insert into users (name, email,school,address, password, updated_at, created_at)

tykus's avatar

Field 'sektor' doesn't have a default value

The problem is wherever you are attempting to create the User, you are not defining the sektor value, and in your migration for users table, there is no default value specified (in the event that a value wasn't provided).

If you share your code which creates the user, we can show you how to work around this issue

tykus's avatar

Try this:

$table->string('sektor')->nullable();
1 like
teguh_rijanandi's avatar

I just want edit default code "insert into users (name, email, password, updated_at, created_at)" to insert into users (name, email, school,address password, updated_at, created_at) ??

tykus's avatar

In what context; you are not being clear about what you are trying to do or how?

Are you using the built-in Authentication system? You would need to modify your RegisterController:

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
        'sektor' => $data['sektor'] // do you have the `sektor` in the request? 
    ]);
}
teguh_rijanandi's avatar

and now Field 'remember_token' doesn't have a default value, how about this?? I was try your suggestion

$table->string('sektor')->nullable();

tykus's avatar

I have not idea what you have done/ are doing... why not make the remember_token field nullable as well since that is the default implementation of the rememberToken() schema builder method - equivalent to

$table->string('remember_token', 100)->nullable();
teguh_rijanandi's avatar

hello guys, whats mean from do you have the sektor in the request??

'sektor' => $data['sektor'] // do you have the sektor in the request?

tykus's avatar

I meant, does your form have a sektor input field?

tykus's avatar

So that will be in the $data array that is received by the RegisterController@create method.

tykus's avatar

Add 'sektor' and whatever else you have added to the form into the $fillable array on the User model.

teguh_rijanandi's avatar

True or Not??

input class="w3-input" maxlength="1" id="sektor" type="text" placeholder="Type 1 Until 5" name="sektor" value="{{ old('sektor') }}" required autofocus>

tykus's avatar
tykus
Best Answer
Level 104

True or Not??

What are you talking about? We were discussing the $fillable property on the model:

// User.php

    protected $fillable = [
        'name', 'email', 'password', 'sektor', // ... 
    ];
1 like
teguh_rijanandi's avatar

Thank you My friends, if you do not help me, surely I will never finish this project

Please or to participate in this conversation.