Laravel中的关系with->profiles()
和->profiles
之间有什么区别?
->profiles
返回相关模型的集合
->profiles()
返回关系的一个实例,如果您想更新相关模型,这很方便
示例:
$posts = $user->posts; // model -> collection
$posts = $user->posts()->get(); // model -> relation -> collection
点击此处阅读更多信息:https://laracasts.com/discuss/channels/eloquent/dynamic-property-vs-method-in-eloquent-orm