title: Laravel model::create() not returning the primary key
body: <p>I have a following auth table:</p>
  <pre><code>&lt;?php
  
  use Illuminate\Database\Migrations\Migration;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Support\Facades\DB;
  use Illuminate\Support\Facades\Schema;
  
  class CreateAuthTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('auth', function (Blueprint $table) {
              $table-&gt;uuid('id')-&gt;primary();
              $table-&gt;string('email', 255)-&gt;index()-&gt;unique();
              $table-&gt;string('password', 96);
              $table-&gt;timestamps();
          });
          DB::statement('ALTER TABLE auth ALTER COLUMN id SET DEFAULT uuid_generate_v4();');
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('auth');
      }
  }
  
  </code></pre>
  <p>And this is the model:</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Foundation\Auth\User as Authenticable;
  use Illuminate\Support\Facades\Hash;
  use Laravel\Passport\HasApiTokens;
  
  class User extends Authenticable
  {
      use HasApiTokens;
  
      protected $table = &quot;auth&quot;;
      protected $fillable = [&quot;email&quot;, &quot;password&quot;];
      public $incrementing = false;
      protected $keyType = 'string';
      protected $casts = [
          'id' =&gt; 'string'
      ];
  
      private $hashOptions = [
          'memory' =&gt; 1024,
          'time' =&gt; 2,
          'threads' =&gt; 1
      ];
  
      public function setPasswordAttribute($value)
      {
          $this-&gt;attributes['password'] = Hash::make($value, $this-&gt;hashOptions);
      }
  }
  
  </code></pre>
  <p>And in <code>UserController</code>, I create users like so:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\User;
  
  use App\Http\Controllers\Controller;
  use App\Models\User;
  use Illuminate\Auth\AuthenticationException;
  use Illuminate\Database\QueryException;
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  use Illuminate\Support\Facades\Validator;
  
  class UserController extends Controller
  {
      public function register(Request $request)
      {
          $validator = Validator::make($request-&gt;all(), [
              &quot;email&quot; =&gt; &quot;required|email|unique:auth&quot;,
              &quot;password&quot; =&gt; &quot;required|string|min:2|max:255&quot;,
              &quot;password_confirm&quot; =&gt; &quot;required|same:password&quot;
          ]);
  
  
          if ($validator-&gt;fails()) {
              return response()-&gt;json($validator-&gt;errors(), 422);
          }
  
          $credentials = $request-&gt;only('email', 'password');
  
          $exists = User::where('email', $credentials['email'])-&gt;first();
          if ($exists) {
              return response()-&gt;json([
                  &quot;error&quot; =&gt; &quot;Email already exists&quot;
              ], 409);
          }
  
          $user = User::create($credentials);
  
          dd($user-&gt;id); // This is always null
  
          return response()-&gt;json([
              'data' =&gt; [
                  &quot;id&quot; =&gt; $user-&gt;id,
                  &quot;email&quot; =&gt; $request-&gt;email,
              ]
          ]);
      }
  }
  
  </code></pre>
  <p>However, the response <code>$user-&gt;id</code> is always null. Shouldn't the <code>Model::create</code> return the id of newly created record?</p>
  <p>I also tried a bunch of combinations like so:</p>
  <pre><code>// Models\User.php
  
  public $incrementing = false;
  protected $keyType = 'string';
  protected $casts = [
      'id' =&gt; 'string'
  ];
  </code></pre>
  <p>But the result is always same. I am using Laravel 7 with Postgres SQL 12.3.</p>