我已将use SoftDeletingTrait;
和protected $dates = ['deleted_at'];
添加到我的Laravel 4.2模型中,但即使我不使用withTrashed()
,它仍会获得已被软删除的记录。
例如,如果我有多个商店,那么Store::all()
和Store::where('condition', $value)->get()
仍然会返回已删除的商店,除非我为这两个商店添加->whereNull('deleted_at')
。
对于像Auth::user()->stores()
这样的关系表也是如此,我仍然需要自定义stores()
方法才能使用->whereNull('deleted_at')
。
我可能在这里做错了什么?