Replies: 2 comments 1 reply
-
I need to go to sleep but i cant see the value of |
Beta Was this translation helpful? Give feedback.
1 reply
-
But the method
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am proposing an enhancement to facilitate retrieving the count of related models directly when a single model instance is fetched, say via the
find()
method. For getting multiple models we already havewithCount
, this idea targets the situations where a single model is retrieved.This feature would streamline operations, enabling syntax like
auth()->user()->posts_count
. By doing so, developers could easily obtain related model counts without additional queries or method calls.I propose implementing this feature through a trait, which could introduce a
getRelationshipCount
method. Additionally, a slight alteration in theModel::_get($key)
method could facilitate this enhancement. Here's a rough outline of how this could be structured:and in Model:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions