title: Laravel boot problem - General error: 1364 Field 'id' doesn't have a default value
body: <p>I use Laravel with MySQL on XAMMP. </p>
  
  <p>I am currently trying to make a simple relationship between my <code>users</code> table and my <code>profiles</code> table. When a new user is created i want to create a profile for that specific user at the same time. Referencing my uuid "id" from the users table to the "user_id" in the profiles table. So i can reference the two in my application. </p>
  
  <p>For that i added a boot function to my "User" model. And im trying</p>
  
  <p>Now when i create a new user i get the following error: </p>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default
    value (SQL: insert into <code>users</code> (<code>name</code>, <code>email</code>, <code>password</code>,
    <code>updated_at</code>, <code>created_at</code>) values (Jesper Deleuran Larsen,
    jesperdeleuranlarsen@gmail.com,
    $2y$10$mA4jZINdWhJXfbBihilI0.Lqmn3L5iTs9m7yI/tAuI5FWBVkIdYxu,
    2019-06-02 19:56:11, 2019-06-02 19:56:11))</p>
  </blockquote>
  
  <p>If i erase the boot function in the User model it works fine and generates a new user but the profiles table is of course empty. So i guess the error is somewhere in the model but i just cant seem to figure out what is wrong. </p>
  
  <p>Since im a beginner please tell me if the whole thing is setup the wrong way.</p>
  
  <p>Much appreciated!</p>
  
  <p>My User model</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App;
  
  use App\Mail\NewUserWelcomeMail;
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Illuminate\Support\Facades\Mail;
  
  class User extends Authenticatable
  {
      use Uuids; //UUID
      use Notifiable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'id', 'name', 'email', 'password',
      ];
      /**
       * Indicates if the IDs are auto-incrementing.
       *
       * @var bool
       */
      public $incrementing = false;
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
      /**
       * The attributes that should be cast to native types.
       *
       * @var array
       */
      protected $casts = [
          'email_verified_at' =&gt; 'datetime',
      ];
  
      protected static function boot()
      {
          parent::boot();
          static::created(function ($user) {
              $user-&gt;profile()-&gt;create();
          });
      }
  
  
      public function profile()
      {
          return $this-&gt;hasOne(Profile::class);
      }
  }
  
  </code></pre>
  
  <p>My migration for the users table</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateUsersTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('users', function (Blueprint $table) {
              $table-&gt;uuid('id');
              $table-&gt;primary('id');
              $table-&gt;string('name');
              $table-&gt;string('email')-&gt;unique();
              $table-&gt;timestamp('email_verified_at')-&gt;nullable();
              $table-&gt;string('password');
              $table-&gt;rememberToken();
              $table-&gt;timestamps();
  
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('users');
      }
  }
  
  </code></pre>
  
  <p>My migration for the profiles table</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateProfilesTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('profiles', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;uuid('user_id');
              $table-&gt;string('company')-&gt;nullable();
              $table-&gt;string('phone')-&gt;nullable();
              $table-&gt;timestamps();
  
              //Linking profiles table to users table
              $table-&gt;index('user_id');
          });
  
  
  
  
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('profiles');
      }
  }
  </code></pre>
  
  <p>My profile model</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Profile extends Model
  {
  
      use Uuids; //UUID
  
      //Disable fillable
      protected $fillable = [
          'id', 'user_id', 'company', 'phone',
      ];
  
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  
  }
  
  </code></pre>
  
  <p>My trait for creating userids = uuids.php</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Webpatser\Uuid\Uuid;
  use Illuminate\Database\Eloquent\Model;
  
  trait Uuids
  {
      /**
       * Boot function from laravel.
       */
      protected static function boot()
      {
          parent::boot();
          static::creating(function ($model) {
              $model-&gt;{$model-&gt;getKeyName()} = Uuid::generate()-&gt;string;
          });
  
  
      }
  
  }
  
  </code></pre>