title: Transformer usage on laravel/dingo API
body: <p>I am creating a set of REST APIs to  be exposed to my mobile apps using laravel repository pattern.I am using dingo as the REST framework.I am confused on how the response for the APIs should be done using a transformer.</p>
  
  <p>I have the below controller function
  </p>
  
  <pre><code>if(!$user) { 
      //Authenticate with Twitter and authenticate
      //Register user and issue jwt
      $user = Sentinel::register($device_details);
      $user_data = json_decode($user,true);
      $device_details['users_id'] = $user['users_id'] = $user_data['id'];
      $this-&gt;device_details-&gt;create($device_details);             
  }
  $token = JWTAuth::fromUser($user);
  $user_array = $user-&gt;toArray();
  $user_array['token'] = $token;   //An array containing user details and token
  return $this-&gt;response-&gt;item($user_array, new UserTransformer)-&gt;setStatusCode(200);   //I can only pass an object (eloquent) as the #1 parameter
  </code></pre>
  
  <p>My Tranformer class
  </p>
  
  <pre><code>namespace App\Api\V1\Transformers;
  
  use App\User;
  use League\Fractal\TransformerAbstract;
  
  class UserTransformer extends TransformerAbstract {
  
      public function transform(User $user)
      {
          return [
              'users_id'     =&gt; (int) $user-&gt;users_id,
              'AUTH-TOKEN'   =&gt; $user-&gt;token // Doesnt comes from database,
  ...
          ];
      }
  }
  </code></pre>
  
  <p>Now my question is,</p>
  
  <ol>
  <li>I can only use eloquent objects with a tranformer?</li>
  <li>Here in this case, the token is generated by jwt library and I binded it with the array as a single user array. Now how will be able to pass this array to a presenter. </li>
  <li>The documention for fractal transformer doesn't say about passing array to the presenter.My data might not always comes from an eloquent object.</li>
  <li>How do I handle this case?</li>
  <li>Why are presenters used? I would either use a presenter or a tranformer right?</li>
  </ol>