From 4ff63e76dbad80f99026ff3051eebf5798e9d0c2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:04:41 +0900 Subject: [PATCH 1/5] docs: fix :returns: --- user_guide_src/source/general/common_functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index b63ee020d380..ed8d41885e19 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -104,7 +104,7 @@ Service Accessors :param string $name: The model classname. :param boolean $getShared: Whether to return a shared instance. :param ConnectionInterface|null $conn: The database connection. - :returns: More simple way of getting model instances + :returns: The model instances :rtype: object See also the :ref:`Using CodeIgniter's Model `. From db475049644eed3b3c7a43e5327f71c595d84f27 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:05:35 +0900 Subject: [PATCH 2/5] docs: add explanation and links --- user_guide_src/source/general/common_functions.rst | 5 +++++ user_guide_src/source/models/model.rst | 3 +++ 2 files changed, 8 insertions(+) diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index ed8d41885e19..4a4f9744e800 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -107,6 +107,11 @@ Service Accessors :returns: The model instances :rtype: object + More simple way of getting model instances. + + The ``model()`` uses ``Factories::models()`` internally. + See :ref:`factories-example` for details on the first parameter ``$name``. + See also the :ref:`Using CodeIgniter's Model `. .. php:function:: old($key[, $default = null,[, $escape = 'html']]) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index dbdbd214f398..a3782c7205ba 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -28,6 +28,9 @@ You can access models within your classes by creating a new instance or using th .. literalinclude:: model/001.php +The ``model()`` uses ``Factories::models()`` internally. +See :ref:`factories-example` for details on the first parameter. + CodeIgniter's Model ******************* From ca40054bc8875128fc111b9524e8c75d80b8d65c Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:06:21 +0900 Subject: [PATCH 3/5] docs: change folder decoration --- user_guide_src/source/models/model.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index a3782c7205ba..726c26dac728 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -21,7 +21,7 @@ updating records, deleting records, and more. Accessing Models **************** -Models are typically stored in the ``app/Models`` directory. They should have a namespace that matches their +Models are typically stored in the **app/Models** directory. They should have a namespace that matches their location within the directory, like ``namespace App\Models``. You can access models within your classes by creating a new instance or using the :php:func:`model()` helper function. From 921dbbe37ee5125668001a1eca6146eae575269f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:08:36 +0900 Subject: [PATCH 4/5] docs: add other samle code --- user_guide_src/source/models/model/001.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/models/model/001.php b/user_guide_src/source/models/model/001.php index 22f30bd5e5ee..d8ef48641ea6 100644 --- a/user_guide_src/source/models/model/001.php +++ b/user_guide_src/source/models/model/001.php @@ -3,11 +3,15 @@ // Create a new class manually. $userModel = new \App\Models\UserModel(); -// Create a new class with the model() function. -$userModel = model('App\Models\UserModel', false); - // Create a shared instance of the model. +$userModel = model('UserModel'); +// or $userModel = model('App\Models\UserModel'); +// or +$userModel = model(App\Models\UserModel::class); + +// Create a new class with the model() function. +$userModel = model('UserModel', false); // Create shared instance with a supplied database connection. // When no namespace is given, it will search through all namespaces From bfffe3d4f526c571ded285cf2fddee9fb926a89a Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:09:39 +0900 Subject: [PATCH 5/5] docs: remove incorrect comment When a FQCN is given, it may search through all namespaces. And the App namespace is prefered by default. --- user_guide_src/source/models/model/001.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/user_guide_src/source/models/model/001.php b/user_guide_src/source/models/model/001.php index d8ef48641ea6..90cdb17d98ea 100644 --- a/user_guide_src/source/models/model/001.php +++ b/user_guide_src/source/models/model/001.php @@ -14,7 +14,5 @@ $userModel = model('UserModel', false); // Create shared instance with a supplied database connection. -// When no namespace is given, it will search through all namespaces -// the system knows about and attempts to locate the UserModel class. $db = db_connect('custom'); $userModel = model('UserModel', true, $db);