foreach ($posts as $post) {
foreach ($post->comments as $c) {
//do something
}
}
As long as the relationship is set correctly, it will be looped like this, similar to nested arrays, and paging usually does not need to be written by yourself.
If you want to get the result of join, just use join instead of with.
Loop
As long as the relationship is set correctly, it will be looped like this, similar to nested arrays, and paging usually does not need to be written by yourself.
If you want to get the result of join, just use join instead of with.
laravel can also directly perform joint query, for example
These are actually included in the document, please read the document carefully before using it