laravel中firstOrCreate的使用

laravel - firstOrCreate(判断是否存在, 不存在则新增数据)

1, 判断goods_name是否存在YKQ003213_G这个参数

2, 不存在则添加数组的内容

3, 需要设置自动填充的白名单

同理的应该还有 updateOrCreate, 方法(未测试)

原文地址:https://www.cnblogs.com/meibao/p/7263712.html