title: Laravel New User Registration via API POST Fail
body: <p>I use Postman to try creating a new user with email and password to the database through laravel</p>
  
  <p>but I do not receive the token after the user is created succesfuly and I receive these instead:</p>
  
  <pre><code>    &lt;!doctype html&gt;
     &lt;html class="theme-light"&gt;
     &lt;!--
  TypeError: Argument 1 passed to Tymon\JWTAuth\JWT::fromUser() must be an instance of Tymon\JWTAuth\Contracts\JWTSubject, instance of App\User given, called in /Users/ahmed/laravelapi/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 261 in file /Users/ahmed/laravelapi/vendor/tymon/jwt-auth/src/JWT.php on line 88
  
  #0 /Users/ahmed/laravelapi/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Tymon\JWTAuth\JWT-&gt;fromUser(Object(App\User))
  #1 /Users/ahmed/laravelapi/app/Http/Controllers/APIRegisterController.php(33): Illuminate\Support\Facades\Facade::__callStatic('fromUser', Array)
  #2 [internal function]: App\Http\Controllers\APIRegisterController-&gt;register(Object(Illuminate\Http\Request))
  #3 /Users/ahmed/laravelapi/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
  #4 /Users/ahmed/laravelapi/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller-&gt;callAction('register', Array)
  #5 /Users/ahmed/laravelapi/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\Routing\ControllerDispatcher-&gt;dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\APIRegisterController), 'register')
  </code></pre>
  
  <p>here is the code inside APIRegisterController.php:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use App\Http\Controllers\Controller;
  use App\User;
  use JWTFactory;
  use JWTAuth;
  use Validator;
  use Response;
  use Illuminate\Http\Request;
  
  class APIRegisterController extends Controller
  {
      public function register(Request $request){
          $validator = Validator::make($request -&gt; all(),[
              'email' =&gt; 'required|string|email|max:255|unique:users',
              'name' =&gt; 'required',
              'password' =&gt; 'required'
      ]);
  
      if ($validator-&gt;fails()) {
          # code...
          return response()-&gt;json($validator-&gt;errors());
      }
  
      User::create([
              'name' =&gt; $request-&gt;get('name'),
              'email' =&gt; $request-&gt;get('email'),
              'password' =&gt; bcrypt($request-&gt;get('password'))
      ]);
  
      $user = User::first();
      $token = JWTAuth::fromUser($user);
  
      return Response::json(compact('token'));
  }
  }
  </code></pre>
  
  <p>Here is User.php model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Illuminate\Notifications\Notifiable;
  
  class User extends Authenticatable
  {
  use Notifiable;
  
  /**
   * The attributes that are mass assignable.
   *
   * @var array
   */
  protected $fillable = [
      'name', 'email', 'password',
  ];
  
  /**
   * 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',
  ];
  
  }
  </code></pre>
  
  <p>Although I receive these errors in the laravel project :</p>
  
  <p>Validator: Undefined type
  JWTAuth : Undefined type
  Response: Undefined type</p>
  
  <p>Can anyone help me to make successful post?</p>