• <small id='kMhhc'></small><noframes id='kMhhc'>

  • <tfoot id='kMhhc'></tfoot>
      <legend id='kMhhc'><style id='kMhhc'><dir id='kMhhc'><q id='kMhhc'></q></dir></style></legend>
    1. <i id='kMhhc'><tr id='kMhhc'><dt id='kMhhc'><q id='kMhhc'><span id='kMhhc'><b id='kMhhc'><form id='kMhhc'><ins id='kMhhc'></ins><ul id='kMhhc'></ul><sub id='kMhhc'></sub></form><legend id='kMhhc'></legend><bdo id='kMhhc'><pre id='kMhhc'><center id='kMhhc'></center></pre></bdo></b><th id='kMhhc'></th></span></q></dt></tr></i><div id='kMhhc'><tfoot id='kMhhc'></tfoot><dl id='kMhhc'><fieldset id='kMhhc'></fieldset></dl></div>

          <bdo id='kMhhc'></bdo><ul id='kMhhc'></ul>
      1. FatalThrowableError:参数 1 已通过 ..::fromUser() laravel 5.6

        FatalThrowableError:Argument 1 passed ..::fromUser() laravel 5.6(FatalThrowableError:参数 1 已通过 ..::fromUser() laravel 5.6)
      2. <i id='wOB4D'><tr id='wOB4D'><dt id='wOB4D'><q id='wOB4D'><span id='wOB4D'><b id='wOB4D'><form id='wOB4D'><ins id='wOB4D'></ins><ul id='wOB4D'></ul><sub id='wOB4D'></sub></form><legend id='wOB4D'></legend><bdo id='wOB4D'><pre id='wOB4D'><center id='wOB4D'></center></pre></bdo></b><th id='wOB4D'></th></span></q></dt></tr></i><div id='wOB4D'><tfoot id='wOB4D'></tfoot><dl id='wOB4D'><fieldset id='wOB4D'></fieldset></dl></div>

        <small id='wOB4D'></small><noframes id='wOB4D'>

        <tfoot id='wOB4D'></tfoot>
          <bdo id='wOB4D'></bdo><ul id='wOB4D'></ul>

              1. <legend id='wOB4D'><style id='wOB4D'><dir id='wOB4D'><q id='wOB4D'></q></dir></style></legend>
                  <tbody id='wOB4D'></tbody>
                1. 本文介绍了FatalThrowableError:参数 1 已通过 ..::fromUser() laravel 5.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用邮递员添加用户或登录,用户添加成功但我收到此错误

                  I use postman to add user or to login , user has added with sucess but I get this error

                  "传递给 TymonJWTAuthJWT::fromUser() 的参数 1 必须是TymonJWTAuthContractsJWTSubject 的实例,AppUser 的实例给定,在 C:UsersWeb 中调用WorkStationDesktoplaravelappjwtlaravelvendor ymonjwt-authsrcJWTAuth.php第 54 行"

                  "Argument 1 passed to TymonJWTAuthJWT::fromUser() must be an instance of TymonJWTAuthContractsJWTSubject, instance of AppUser given, called in C:UsersWeb WorkStationDesktoplaravelappjwtlaravelvendor ymonjwt-authsrcJWTAuth.php on line 54"

                  我在这个 ligne 中找到了这个函数

                  and I found in this ligne this founction

                   public function attempt(array $credentials)
                      {
                          if (! $this->auth->byCredentials($credentials)) {
                              return false;
                          }
                  
                          return $this->fromUser($this->user());
                      }
                  

                  这是我的用户模型:

                      <?php
                  
                      namespace App;
                  
                  
                      use TymonJWTAuthContractsJWTSubject;
                      use IlluminateNotificationsNotifiable;
                      use IlluminateFoundationAuthUser as Authenticatable;
                      class User extends Authenticatable
                      {
                          use Notifiable;
                  
                          /**
                           * The attributes that are mass assignable.
                           *
                           * @var array
                           */
                          protected $fillable = [
                              'name', 'email', 'password','username','lastname','tel','tel',
                          ];
                  
                          /**
                           * The attributes that should be hidden for arrays.
                           *
                           * @var array
                           */
                          protected $hidden = [
                              'password', 'remember_token',
                          ];
                          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 [];
                          }
                      }
                  and this my register controller
                  
                  <?php
                  
                  namespace AppHttpControllers;
                  use AppHttpControllersController;
                  use IlluminateHttpRequest;
                  use AppUser;
                  use JWTFactory;
                  use JWTAuth;
                  use Validator;
                  use Response;
                  
                  class APIRegisterController extends Controller
                  {
                      //
                      public function register( Request $request){
                          $validator = Validator::make($request -> all(),[
                           'email' => 'required|string|email|max:255|unique:users',
                           'username' =>'required',
                           'tel' => 'required',
                           'name' => 'required',
                           'lastname' => 'required',
                           'adress' => 'required',
                           'password'=> 'required'
                          ]);
                  
                          if ($validator -> fails()) {
                              # code...
                              return response()->json($validator->errors());
                  
                          }
                  
                          User::create([
                              'name' => $request->get('name'),
                              'email' => $request->get('email'),
                              'tel' => $request->get('tel'),
                              'username' => $request->get('username'),
                              'lastname' => $request->get('lastname'),
                              'adress' => $request->get('adress'),
                              'password'=> bcrypt($request->get('password'))
                          ]);
                          $user = User::first();
                          $token = JWTAuth::fromUser($user);
                  
                          return Response::json( compact('token'));
                  
                  
                      }
                  }
                  

                  推荐答案

                  在你的 User 模型中实现 JWTSubject:

                  Implement the JWTSubject in your User model:

                  class User extends Authenticatable implements JWTSubject
                  

                  这篇关于FatalThrowableError:参数 1 已通过 ..::fromUser() laravel 5.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <legend id='CFHOc'><style id='CFHOc'><dir id='CFHOc'><q id='CFHOc'></q></dir></style></legend>
                2. <tfoot id='CFHOc'></tfoot>
                  <i id='CFHOc'><tr id='CFHOc'><dt id='CFHOc'><q id='CFHOc'><span id='CFHOc'><b id='CFHOc'><form id='CFHOc'><ins id='CFHOc'></ins><ul id='CFHOc'></ul><sub id='CFHOc'></sub></form><legend id='CFHOc'></legend><bdo id='CFHOc'><pre id='CFHOc'><center id='CFHOc'></center></pre></bdo></b><th id='CFHOc'></th></span></q></dt></tr></i><div id='CFHOc'><tfoot id='CFHOc'></tfoot><dl id='CFHOc'><fieldset id='CFHOc'></fieldset></dl></div>
                    <bdo id='CFHOc'></bdo><ul id='CFHOc'></ul>

                    <small id='CFHOc'></small><noframes id='CFHOc'>

                          <tbody id='CFHOc'></tbody>