Jwt-auth: Interface 'Tymon\JWTAuth\Contracts\JWTSubject' not found

Created on 11 Jan 2018  路  2Comments  路  Source: tymondesigns/jwt-auth

Hi,
i have tried use the guide
quick-start.md

version in composer: "tymon/jwt-auth": "0.5.*"

User Model

`

namespace App\Models;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\AuthUser as Authenticatable;
use App\Models\Project;

class User extends Authenticatable implements JWTSubject
{
use Notifiable;

/**
 * Get the identifier that will be stored in the subject claim of the JWT.
 *
 * @return mixed
 */
public function getJWTIdentifier()
    {
        return $this->getKey();
    }

/**
 * Return a key value array, containing any custom claims to be added to the JWT.
 *
 * @return array
 */
public function getJWTCustomClaims()
    {
        return [];
    }
/**
 * Questi attributi possono essere modificati
 *
 * @var array
 */
protected $fillable = [
    'name', 'email', 'password',
];

/**
 * Questi attributi non potranno essere visti nella chiamata rest
 *
 * @var array
 */
protected $hidden = [
    'password', 'remember_token'
];

/**
 * @return \Illuminate\Database\Eloquent\Relations\HasMany
 */
public function projects(){
    $propertyInProject="user_id";
    $propertyForeignWithProject="id";
    return $this->hasMany(Project::class,$propertyInProject,$propertyForeignWithProject);
}

}
`

before use the guide the model worked fine (i retrived always the token).

ERROR

(1/1)聽FatalErrorExceptionInterface 'Tymon\JWTAuth\Contracts\JWTSubject' not found

in聽User.php聽(line 12)

Most helpful comment

looks like you are looking at the docs for version 1.0.0 instead of 0.5.*.. You will either need to update to 1.0.0 or see the wiki for 0.5 docs

All 2 comments

looks like you are looking at the docs for version 1.0.0 instead of 0.5.*.. You will either need to update to 1.0.0 or see the wiki for 0.5 docs

/**

  • Get the identifier that will be stored in the subject claim of the JWT.
    *
  • @return mixed
    */
    public function getJWTIdentifier()
    {
    return $this->getKey();
    }

/**

  • Return a key value array, containing any custom claims to be added to the JWT.
    *
  • @return array
    /
    public function getJWTCustomClaims()
    {
    return [];
    }
    /
    *
  • Questi attributi possono essere modificati
    *
  • @var array
    */
    protected $fillable = [
    'name', 'email', 'password',
    ];

/**

  • Questi attributi non potranno essere visti nella chiamata rest
    *
  • @var array
    */
    protected $hidden = [
    'password', 'remember_token'
    ];

/**

  • @return \IlluminateDatabaseEloquent\RelationsHasMany
    */
    public function projects(){
    $propertyInProject="user_id";
    $propertyForeignWithProject="id";
    return $this->hasMany(Project::class,$propertyInProject,$propertyForeignWithProject);
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

phamduong picture phamduong  路  3Comments

therealmjk picture therealmjk  路  3Comments

heroghost picture heroghost  路  3Comments

CBR09 picture CBR09  路  3Comments

johncloud200 picture johncloud200  路  3Comments