Custom payload with Laravel JWT
<p>I am using Laravel 5.3 and <a href="https://github.com/tymondesigns/jwt-auth" rel="noreferrer">laravel jwt</a> for token, here is the list of namespaces used by the controller.</p>

<pre><code>use JWTAuth;
use App\Http\Requests;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Facades\JWTFactory;
use Tymon\JWTAuth\Exceptions\JWTException;
</code></pre>

<p>I need to add custom payload data to generate the token.</p>

<p>Here is how i am trying to generate token with custom payloads.</p>

<pre><code>        $payloadable = [
            'id' =&gt; $tokenPayload-&gt;id,
            'name' =&gt; $tokenPayload-&gt;name,
            'email' =&gt; $tokenPayload-&gt;email,
            'deleted_at' =&gt; $tokenPayload-&gt;deleted_at,
            'created_at' =&gt; $tokenPayload-&gt;created_at,
            'updated_at' =&gt; $tokenPayload-&gt;updated_at,
            'organization' =&gt; $request-&gt;organization_id
        ];

        // Generate the token.
        $token = JWTAuth::encode( JWTFactory::make( $payloadable ) );

        // Return token.
        return response()-&gt;json( [ 'token' =&gt; $token ] );
</code></pre>

<p>But in the response the token is empty! Here is the response</p>

<pre><code>{
  "token": {}
}
</code></pre>

<p>Why it is returning an empty token instead of a jwt token!</p>

<p><strong>Update:</strong></p>

<p>Now i can get the token using a <code>\</code> before the <code>JWTFactory</code> namespace, but how I will be able to get the updated token value?</p>

<p>What I am trying to achive is to add some additional fields to an existing token, after reading Laravel JWT-auth doc, i figured out that i need to create another token which would have the additional fields but the new token is not returning additional fields.</p>