getChanges()无法与updateOrInsert()

时间:2019-06-26 20:13:34

标签: laravel-5.7

尝试将getChanges()与updateOrInsert()一起使用时出现错误

异常跟踪:

1 Illuminate \ Database \ Eloquent \ Builder :: throwBadMethodCallException(“ getChanges”)       /var/www/vhosts/example.com/httpdocs/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:36

2 Illuminate \ Database \ Eloquent \ Builder :: forwardCallTo(Object(Illuminate \ Database \ Query \ Builder),“ getChanges”,[])       /var/www/vhosts/example.com/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1341

getChanges()与updateOrCreate()一起正常工作,但这不是我需要的方法

$model = Productprice::updateOrInsert(['productcode' => $productPrice['productcode'], 'supplier' => $productPrice['supplier']], $productPrice);
                        if (true) {
                            $changes = $model->getChanges();
                            echo 'a change was made';
                            var_dump($changes);
                         }else{
                             echo 'no change';
                         }

我需要能够查看正在更改或插入的记录。 getDirty()也不能与updateOrInsert()一起使用。

我不明白什么?

0 个答案:

没有答案