我有一个News模型,当我查询新闻时,我希望默认情况下它可以带来状态为1的新闻。
News::all(); // select * from news where status = 1
News::where('anotherColumn',2)->get(); // select * from news where status = 1 and where category = 2
这是否可能?我想要的功能非常类似于软删除功能(即获取已删除数据,其中deleted_at不为null,如果需要所有数据,则可以使用withTrashed函数)。
我查看了文档,但没有找到任何有用的信息。此外,我试图在新闻模型的构造函数中处理它,但也没有起作用。
谢谢。