Skip to content

Commit 80b2e4d

Browse files
authored
Merge pull request #7183 from kenjis/fix-docs-about-model-func
docs: fix model() descriptions
2 parents 3c0ac2d + bfffe3d commit 80b2e4d

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

user_guide_src/source/general/common_functions.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,14 @@ Service Accessors
104104
:param string $name: The model classname.
105105
:param boolean $getShared: Whether to return a shared instance.
106106
:param ConnectionInterface|null $conn: The database connection.
107-
:returns: More simple way of getting model instances
107+
:returns: The model instances
108108
:rtype: object
109109

110+
More simple way of getting model instances.
111+
112+
The ``model()`` uses ``Factories::models()`` internally.
113+
See :ref:`factories-example` for details on the first parameter ``$name``.
114+
110115
See also the :ref:`Using CodeIgniter's Model <accessing-models>`.
111116

112117
.. php:function:: old($key[, $default = null,[, $escape = 'html']])

user_guide_src/source/models/model.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ updating records, deleting records, and more.
2121
Accessing Models
2222
****************
2323

24-
Models are typically stored in the ``app/Models`` directory. They should have a namespace that matches their
24+
Models are typically stored in the **app/Models** directory. They should have a namespace that matches their
2525
location within the directory, like ``namespace App\Models``.
2626

2727
You can access models within your classes by creating a new instance or using the :php:func:`model()` helper function.
2828

2929
.. literalinclude:: model/001.php
3030

31+
The ``model()`` uses ``Factories::models()`` internally.
32+
See :ref:`factories-example` for details on the first parameter.
33+
3134
CodeIgniter's Model
3235
*******************
3336

user_guide_src/source/models/model/001.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
// Create a new class manually.
44
$userModel = new \App\Models\UserModel();
55

6-
// Create a new class with the model() function.
7-
$userModel = model('App\Models\UserModel', false);
8-
96
// Create a shared instance of the model.
7+
$userModel = model('UserModel');
8+
// or
109
$userModel = model('App\Models\UserModel');
10+
// or
11+
$userModel = model(App\Models\UserModel::class);
12+
13+
// Create a new class with the model() function.
14+
$userModel = model('UserModel', false);
1115

1216
// Create shared instance with a supplied database connection.
13-
// When no namespace is given, it will search through all namespaces
14-
// the system knows about and attempts to locate the UserModel class.
1517
$db = db_connect('custom');
1618
$userModel = model('UserModel', true, $db);

0 commit comments

Comments
 (0)