[英] How to exclude certains columns while using eloquent
当我使用eloquent时,我可以使用"where"方法,然后使用"get"方法来填充包含我在数据库中选择的内容的对象.
$users = User::where('gender', 'M')->where('is_active', 1)->get(['pseudo', 'email', 'age', 'created_at'])->toArray();
在这里,我可以选择想要获取的列,如"伪"、"邮箱"等. 但我在"Laravel doctor "中错过的是做相反事情的方式. 可能是这样的:
$users = User::where('gender', 'M')->where('is_active', 1)->notGet(['pseudo', 'email', 'age', 'created_at'])->toArray();
谢谢你future 的回答,祝你有愉快的一天.