久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='OVMvr'></bdo><ul id='OVMvr'></ul>
  • <legend id='OVMvr'><style id='OVMvr'><dir id='OVMvr'><q id='OVMvr'></q></dir></style></legend>

    1. <tfoot id='OVMvr'></tfoot>
    2. <i id='OVMvr'><tr id='OVMvr'><dt id='OVMvr'><q id='OVMvr'><span id='OVMvr'><b id='OVMvr'><form id='OVMvr'><ins id='OVMvr'></ins><ul id='OVMvr'></ul><sub id='OVMvr'></sub></form><legend id='OVMvr'></legend><bdo id='OVMvr'><pre id='OVMvr'><center id='OVMvr'></center></pre></bdo></b><th id='OVMvr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OVMvr'><tfoot id='OVMvr'></tfoot><dl id='OVMvr'><fieldset id='OVMvr'></fieldset></dl></div>

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

      1. 用戶注冊時自動創建個人資料(Laravel 5)

        Automaticly make a profile when user registers (Laravel 5)(用戶注冊時自動創建個人資料(Laravel 5))

        1. <small id='5ETsN'></small><noframes id='5ETsN'>

            <tbody id='5ETsN'></tbody>
          <legend id='5ETsN'><style id='5ETsN'><dir id='5ETsN'><q id='5ETsN'></q></dir></style></legend>
              • <bdo id='5ETsN'></bdo><ul id='5ETsN'></ul>
                • <tfoot id='5ETsN'></tfoot>
                • <i id='5ETsN'><tr id='5ETsN'><dt id='5ETsN'><q id='5ETsN'><span id='5ETsN'><b id='5ETsN'><form id='5ETsN'><ins id='5ETsN'></ins><ul id='5ETsN'></ul><sub id='5ETsN'></sub></form><legend id='5ETsN'></legend><bdo id='5ETsN'><pre id='5ETsN'><center id='5ETsN'></center></pre></bdo></b><th id='5ETsN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5ETsN'><tfoot id='5ETsN'></tfoot><dl id='5ETsN'><fieldset id='5ETsN'></fieldset></dl></div>
                • 本文介紹了用戶注冊時自動創建個人資料(Laravel 5)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試為我的注冊用戶制作個人資料頁面.在此頁面上,將顯示 AuthUser 數據(姓名、電子郵件)以及額外的個人資料信息(城市、國家/地區、電話號碼等).

                  I'm trying to make a profile page for my registered users. On this page the AuthUser data will be displayed (Name, Email) but also extra profile information (city, country, phone number, ..).

                  我已經建立了一對一的關系,但我遇到了一個問題.創建用戶后,我希望自動為該特定用戶創建個人資料.

                  I've already made the one to one relationship but I'm having one issue. When a User gets created, I would like to automaticly have a Profile created for that specific user.

                  目前我只是通過 tinker 添加了我的第一個用戶的個人資料,但是一旦我創建了第二個用戶 &轉到個人資料頁面,它出錯了(看到個人資料尚未制作).

                  At the moment I simply added the profile for my first user through tinker, but as soon as I made a second user & went to the profile page, it gave an error (seeing the profile had not been made yet).

                  在 Profile.php 中我有:

                  In the Profile.php I have:

                  <?php namespace App;
                  
                  use IlluminateDatabaseEloquentModel;
                  
                  class Profile extends Model {
                  
                      protected $table = 'profiles';
                      protected $fillable = ['city', 'country', 'telephone'];
                  
                      public function User()
                      {
                          return $this->belongsTo('AppUser');
                      }
                  
                  }
                  

                  在 User.php 中我添加了:

                  In the User.php I added:

                  <?php namespace App;
                  
                  ...
                  
                  class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
                  
                      use Authenticatable, CanResetPassword;
                  
                      ...
                  
                      protected $table = 'users';
                  
                      protected $fillable = ['name', 'lastname', 'email', 'password'];
                  
                      protected $hidden = ['password', 'remember_token'];
                  
                  
                      public function Profile()
                      {
                          return $this->hasOne('AppProfile');
                      }
                  }
                  

                  我像這樣顯示個人資料數據(在我的 profile.blade.php 頁面上):

                  I show the Profile data like this (on my profile.blade.php page):

                  Full name: {{ Auth::user()->name }} {{ Auth::user()->lastname }}
                  E-Mail Address: {{ Auth::user()->email}}
                  
                  
                  City: {{ Auth::User()->profile->city}}
                  Country: {{ Auth::User()->profile->country}}
                  Phone number: {{ Auth::User()->profile->telephone}}
                  

                  我猜我需要向AuthenticatesAndRegistersUsers"特征和Registrar.php"服務添加一些內容,但我不知道是什么.

                  I'm guessing I need to add something to the 'AuthenticatesAndRegistersUsers' trait and the 'Registrar.php' service, but I have no idea what.

                  謝謝,

                  塞德里克

                  推薦答案

                  正如對您問題的評論中所述,我相信這里的最佳答案是將兩個模型合并為一個 User 模型.

                  As noted in the comments on your question I believe the best answer here is to combine the two models into one User model.

                  但是,如果您想在創建用戶時為其創建關系,您可以修改注冊服務.

                  However, if you want to create a relationship on your user when it is created you can modify the Registrar service.

                  AuthenticatesAndRegistersUsers trait 將使用注冊器(默認位于 app/Services/Registrar.php)來驗證和注冊用戶.

                  The AuthenticatesAndRegistersUsers trait will use the registrar (located in app/Services/Registrar.php by default) to validate and register users.

                  你可以修改里面的create方法,同時自動創建profile關系:

                  You can just modify the create method in there to automatically create the profile relation at the same time:

                  public function create(array $data)
                  {
                      $user = User::create([
                          'name' => $data['name'],
                          'email' => $data['email'],
                          'password' => bcrypt($data['password']),
                      ]);
                      $user->profile()->save(new Profile);
                      return $user;
                  }
                  

                  這篇關于用戶注冊時自動創建個人資料(Laravel 5)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                  <i id='EZZGA'><tr id='EZZGA'><dt id='EZZGA'><q id='EZZGA'><span id='EZZGA'><b id='EZZGA'><form id='EZZGA'><ins id='EZZGA'></ins><ul id='EZZGA'></ul><sub id='EZZGA'></sub></form><legend id='EZZGA'></legend><bdo id='EZZGA'><pre id='EZZGA'><center id='EZZGA'></center></pre></bdo></b><th id='EZZGA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EZZGA'><tfoot id='EZZGA'></tfoot><dl id='EZZGA'><fieldset id='EZZGA'></fieldset></dl></div>

                    <tbody id='EZZGA'></tbody>

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

                      <tfoot id='EZZGA'></tfoot>

                        <legend id='EZZGA'><style id='EZZGA'><dir id='EZZGA'><q id='EZZGA'></q></dir></style></legend>

                          <bdo id='EZZGA'></bdo><ul id='EZZGA'></ul>
                            主站蜘蛛池模板: 精品国产乱码久久久久久老虎 | 国产精品区二区三区日本 | 伊人网伊人 | 国产精品一区二区三区四区五区 | 精品小视频 | 中文字幕欧美日韩一区 | 亚洲人人 | 欧美激情欧美激情在线五月 | 欧美最猛黑人 | av一区在线观看 | 免费美女网站 | 国产乱码精品一区二区三区av | 亚洲成人福利视频 | 日韩精品久久一区二区三区 | 成人av电影免费在线观看 | 三区在线 | 成人欧美一区二区三区色青冈 | 日韩精品成人 | 婷婷综合久久 | 亚洲国产片 | 九色网址 | 欧美日韩久久 | 911精品美国片911久久久 | 精品视频久久久久久 | 成人精品视频 | 日本成人在线网址 | 91精品久久久久久综合五月天 | av影音资源 | 午夜大片| 久久久久久天堂 | 欧美国产一区二区 | 国产精品久久久久久久午夜片 | 91视频入口 | 1000部精品久久久久久久久 | 性一交一乱一伦视频免费观看 | 免费视频99 | 国产精品不卡 | 国产精品一区二区三区四区五区 | 亚洲国产一区二区三区在线观看 | 国际精品鲁一鲁一区二区小说 | 一区二区三区四区视频 |