在我的项目中,我有许多Eloquent模型,它们在类中配置了如下所示的热切关系:
protected $with = [ 'countries', 'roles' ];
Run Code Online (Sandbox Code Playgroud)
但有时我只需要旧的普通模型而没有任何关系.我能以某种方式做到:
Model::noRelations()->all()
Run Code Online (Sandbox Code Playgroud)
真的不想使用查询构建器,也不想在少数情况下创建另一个类.