laravel 用模型更新表全部数据写法

我想用模型更新一个表的全部数据,但是必须加个where条件才可以更新, 直接去掉where就会报错Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context。加这个where看着又别扭,且没啥实际意义,代码如下:

Goods::where(DB::raw(1), 1)->update([
    'start_time' => $start_time
]);

能去掉这个where嘛?
试过用 (new Goods)->update(['start_time' => $start_time]),但是实际没任何sql执行, 也不想用DB::table('goods')->update()这种更新方式~.

摇曳的蔷薇
浏览 910回答 2
2回答

守着一只汪

Goods::query()->update([]);
打开App,查看更多内容
随时随地看视频慕课网APP