mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 10:14:16 +08:00
Eager load ListPostsController needed relations (#2717)
* Eager load ListPostsController needed relations * Add comment explaining the reason for eagerloading
This commit is contained in:
parent
8dd57ffed2
commit
3cc18c1da2
|
@ -93,6 +93,17 @@ class ListPostsController extends AbstractListController
|
||||||
$results->areMoreResults() ? null : 0
|
$results->areMoreResults() ? null : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Eager load discussion for use in the policies,
|
||||||
|
// eager loading does not affect the JSON response,
|
||||||
|
// the response only includes relations included in the request.
|
||||||
|
if (! in_array('discussion', $include)) {
|
||||||
|
$include[] = 'discussion';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('user', $include)) {
|
||||||
|
$include[] = 'user.groups';
|
||||||
|
}
|
||||||
|
|
||||||
return $results->getResults()->load($include);
|
return $results->getResults()->load($include);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user