pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="t3o7nhj" 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="lxou6km" 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="har8wb2" 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>
                            主站蜘蛛池模板: 压砖机_电动螺旋压力机_粉末成型压力机_郑州华隆机械tel_0371-60121717 | 广东恩亿梯电源有限公司【官网】_UPS不间断电源|EPS应急电源|模块化机房|电动汽车充电桩_UPS电源厂家(恩亿梯UPS电源,UPS不间断电源,不间断电源UPS) | 钢结构-钢结构厂房-钢结构工程[江苏海逵钢构厂] | 电表箱-浙江迈峰电力设备有限公司-电表箱专业制造商 | 冻干机(冷冻干燥机)_小型|实验型|食品真空冷冻干燥机-松源 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 | 清水混凝土修复_混凝土色差修复剂_混凝土色差调整剂_清水混凝土色差修复_河南天工 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 柴油发电机组_柴油发电机_发电机组价格-江苏凯晨电力设备有限公司 | 北京中创汇安科贸有限公司| 电动球阀_不锈钢电动球阀_电动三通球阀_电动调节球阀_上海湖泉阀门有限公司 | 工控机,嵌入式主板,工业主板,arm主板,图像采集卡,poe网卡,朗锐智科 | 海外仓系统|国际货代系统|退货换标系统|WMS仓储系统|海豚云 | sfp光模块,高速万兆光模块工厂-性价比更高的光纤模块制造商-武汉恒泰通 | 釜溪印象网络 - Powered by Discuz! | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 撕碎机,撕破机,双轴破碎机-大件垃圾破碎机厂家 | 钢衬四氟管道_钢衬四氟直管_聚四氟乙烯衬里管件_聚四氟乙烯衬里管道-沧州汇霖管道科技有限公司 | 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 无菌水质袋-NASCO食品无菌袋-Whirl-Pak无菌采样袋-深圳市慧普德贸易有限公司 | 跨境物流_美国卡派_中大件运输_尾程派送_海外仓一件代发 - 广州环至美供应链平台 | 齿轮减速电机一体机_蜗轮蜗杆减速马达-德国BOSERL齿轮减速机带电机生产厂家 | 懂研帝_专业SCI论文润色机构_SCI投稿发表服务公司 | 控显科技 - 工控一体机、工业显示器、工业平板电脑源头厂家 | 北京发电机出租_发电机租赁_北京发电机维修 - 河北腾伦发电机出租 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 房车价格_依维柯/大通/东风御风/福特全顺/江铃图片_云梯搬家车厂家-程力专用汽车股份有限公司 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 福州时代广告制作装饰有限公司-福州广告公司广告牌制作,福州展厅文化墙广告设计, | 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 广州工业氧气-工业氩气-工业氮气-二氧化碳-广州市番禺区得力气体经营部 | 布袋式除尘器|木工除尘器|螺旋输送机|斗式提升机|刮板输送机|除尘器配件-泊头市德佳环保设备 | EFM 022静电场测试仪-套帽式风量计-静电平板监测器-上海民仪电子有限公司 | 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 球磨机,节能球磨机价格,水泥球磨机厂家,粉煤灰球磨机-吉宏机械制造有限公司 | SDG吸附剂,SDG酸气吸附剂,干式酸性气体吸收剂生产厂家,超过20年生产使用经验。 - 富莱尔环保设备公司(原名天津市武清县环保设备厂) | 防爆暖风机_防爆电暖器_防爆电暖风机_防爆电热油汀_南阳市中通智能科技集团有限公司 | 酒精检测棒,数显温湿度计,酒安酒精测试仪,酒精检测仪,呼气式酒精检测仪-郑州欧诺仪器有限公司 | 轴流风机-鼓风机-离心风机-散热风扇-罩极电机,生产厂家-首肯电子 | 珠光砂保温板-一体化保温板-有釉面发泡陶瓷保温板-杭州一体化建筑材料 | 天津力值检测-天津管道检测-天津天诚工程检测技术有限公司 |