Where does the getRecent() method originate from? |
From the docs,
PHP Code: <?php Where does the getRecent() method come from?
It looks like a bug. Models don't have when(), getRecent() methods
Query Builder has when().
See https://codeigniter4.github.io/CodeIgnit...ilder-when The getRecent() seems to be a custom method in PostModel.
Quote:The getRecent() seems to be a custom method in PostModel. Since it wasn't stated clearly that it is a custom method, one will begin to wonder (just like me) where the method comes from. I suggest that the docs should stick with non-custom methods/functions. WDYT?
Indeed, it is preferable to have the code work as it is as much as possible.
Does the model return Query Builder directly? VS Code does not have type hints
Yes, i known. We are talking about an example in documentation.
$this->post = model('PostModel')->when() there is no autocomplete because it is not a builder
Oh, I get you. For that to work, the method will need to be added to the system/Model's class phpdoc @method keyword.
WDYT @kenjis ? Meanwhile, I submitted a PR for the view cell docs: https://github.com/codeigniter4/CodeIgniter4/pull/7805 (08-09-2023, 06:01 PM)sammyskills Wrote: Oh, I get you. For that to work, the method will need to be added to the system/Model's class phpdoc @method keyword. Yes, if a Query Builder method returns $this and the method can be used in Models without problems, we can add to the system/Model's class phpdoc @method keyword. Adding it is fine by me. |
Welcome Guest, Not a member yet? Register Sign In |