Answer the question
In order to leave comments, you need to log in
When should and should not parentheses be used in relations?
For example, we have an association of authors with posts. You can write like this in laravel $author->post()
and like this $author->post
The documentation just says what can be a dynamic property.
Can someone clarify this point?
Answer the question
In order to leave comments, you need to log in
$author->post()
returns the query builder, so you can continue calling the query builder's methods, e.g.
And in the second case, you immediately get a model or a collection of models.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question