dimanche 29 octobre 2017

Laravel: Eloquent query ignores provided data to insert?

I have a user model and I want to create a new row in the database like this:

Route::get('test',function(){

  $alias = \App\Helper\Alias::create(session('firstname') . ' ' . session('surname'));

  $user =  App\User::create([
      'username' => '123213123',
      'gender' => session('gender'),
      'title' => session('title'),
      'name' => session('firstname'),
      'vorname' => session('surname'),
      'geb' => session('brithday'),
      'email' => session('email'),
      'hideEmail' => session('emailVis'),
      'website' => session('website'),
      'tel' => session('tel'),
      'idSprache' => session('langC'),
      'bemerkungAnmeldung' => session('bem'),
      'alias' => $alias,
      'modeIN' => session('mode'),
  ]);
});

Now as soon as I go to /test/ in the browser I get the following error:

SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value (SQL: insert into profileMember (name, email, updated_at, created_at) values (Adam, test@mail.com, 2017-10-29 14:57:11, 2017-10-29 14:57:11)) enter image description here

The error is right: There is no default value for username and in the shown query there is no value given for username. However, in the above code I clearly provided the value 123213123 for the field username. Why is it ignored?


Some additional Screen shots:

Last application frame: enter image description here

Migration file:

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zVRhpH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire