I need to register a new user and store data in two tables separately, the Users table will hold classic id /name / email / password information while the User_details table will hold different information related to the new registered user, for example gender, age, user_pic etc. Now, is there a way to modify the standard authcontroller and stuff from laravel 5.1 to accomplish that task? I mean, how do you tell the controller in the create function to use two different tables? AFAIK the authcontroller now uses User model to store the data in the DB but I need to use also the User_detail model because that is where I specify the fillable columns of my User_detail table. Any clue? Thanks
1条回答 默认 最新
- douqingzhi0980 2015-06-26 07:21关注
Modify
AuthController
'screate()
function. If you have added relation for your model you can easily add this it somewhat it would be like this$user =User::create($data); $user_details = new User_Detail(); $user_details->fill($data); //If your have added fillable in User_Detail return $user_details->save($user);
This create function is called in
RegistersUsers
trait, For more information about inserting related models.解决 无用评论 打赏 举报
悬赏问题
- ¥15 BP神经网络控制倒立摆
- ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
- ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
- ¥30 Unity接入微信SDK 无法开启摄像头
- ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
- ¥20 cad图纸,chx-3六轴码垛机器人
- ¥15 移动摄像头专网需要解vlan
- ¥20 access多表提取相同字段数据并合并
- ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
- ¥20 Java-Oj-桌布的计算