简体   繁体   English

向表中添加了新列,但updateOrCreate方法不会更新-Laravel

[英]Added new column to a table but updateOrCreate method won't update - Laravel

I just added a new column with php artisan make:migration , and after that I called updateOrCreate method hoping to filling the new column with values on all the existing records. 我只是用php artisan make:migration添加了一个新列,然后调用了updateOrCreate方法,希望用所有现有记录中的值填充新列。

But nothing happened. 但是什么也没发生。 I tracked down and found that the parameter for the new column was passed right to updateOrCreate method. 我跟踪发现,新列的参数已正确传递给updateOrCreate方法。 But why was it not working? 但是为什么它不起作用? Thanks. 谢谢。

正如Jeemusu指出的那样,只是为了结束问题并给出答案,您需要在表模型内的$fillable数组中添加新列-从而将其插入数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM