title: Laravel + JWT - User Not Found
body: <p>I'm currently implementing JWT in my project to support an API of sorts. This API is only available for a specific <code>model</code>. This model works correctly using the custom guard I've declared when I want to log it in, I've ensured the contracts and authenticatable traits have been properly applied, yet the <code>-&gt;byId</code> method always fails. Here's my code:</p>
  
  <pre><code>namespace App;
  
  class Customer extends Model implements Authenticatable {
  
      use \Illuminate\Auth\Authenticatable;
  </code></pre>
  
  <p>In my <code>jwt.php</code> file, I've told it to use my custom model:</p>
  
  <pre><code>'user' =&gt; \App\Customer::class,
  </code></pre>
  
  <p>When I execute:</p>
  
  <pre><code>JWTAuth::fromUser($customer);
  </code></pre>
  
  <p>I receive a proper token.</p>
  
  <p>I then use Postman to check this by passing it with the <code>Authorization: Bearer &lt;token&gt;</code> header. The token is correctly set.</p>
  
  <p>For subsequent requests to my protected route, I then attempt to authenticate the user in this way:</p>
  
  <pre><code>$token = JWTAuth::parseToken()-&gt;authenticate();
  </code></pre>
  
  <p><code>-&gt;authenticate()</code> always fails.</p>
  
  <p>The reason it fails is due to this:</p>
  
  <pre><code> if (! $this-&gt;auth-&gt;byId($id)) {
          return false;
   }
  </code></pre>
  
  <p>This always returns false.</p>
  
  <p>However, resolving the <code>id</code> from the <code>$id = $this-&gt;getPayload($token)-&gt;get('sub');</code> call does provide me with the valid ID for this particular Customer. Further, the model is actually a traditional model, where the PK is the <code>id</code> column, and my identifier is set correctly:</p>
  
  <pre><code>'identifier' =&gt; 'id',
  </code></pre>
  
  <p>Why is the <code>EloquentUserAdapter</code> not able to resolve an instance of my <code>Customer</code>?</p>
  
  <p>I've scoured Google and have attempted a variety of fixes, but nothing has come to fruition. Any help would be greatly appreciated.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I've dumped the SQL query that was executed, and the table it attempts to reference is my default User model, it is not my custom model. Why is that?</p>
  
  <p><strong>Update 2</strong>
  The <code>tymon.jwt.provider.user</code> singleton bound to the UserInterface correctly references my custom model:</p>
  
  <pre><code>return $app['tymon.jwt.provider.user'];
  </code></pre>
  
  <p>Provides:</p>
  
  <pre><code>EloquentUserAdapter {#849
      #user: Customer {#850
      #primaryKey: "id"
      #table: "customers"
  </code></pre>
  
  <p><strong>Update 3</strong></p>
  
  <p>In booting the JWT User provider, it knows which model I want to use:</p>
  
  <pre><code>$model = $app-&gt;make($this-&gt;config('user'));
  </code></pre>
  
  <p>Yields:</p>
  
  <pre><code>Customer {#1040
      #primaryKey: "id"
      #table: "customers"
  </code></pre>