File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -2418,14 +2418,15 @@ numerous useful methods for working on HTTP interactions.
2418
2418
Model Instance
2419
2419
##############
2420
2420
2421
- Often, a controller works with a specific model and through the $model
2422
- property it is possible to set the Fully Qualified Class Name of a
2423
- ``ModelInterface `` child class so that an instance of it is automatically loaded,
2424
- in all requests, in the construction of the controller.
2421
+ Each controller can have a ``$model `` property, which will be automatically
2422
+ instantiated in the class constructor.
2425
2423
2426
- Let's see below that $model receives the type name of the ``App\Models\UsersModel ``
2427
- class and in the ``show `` method the direct call to the $model property is used,
2428
- which has the instance of ``App\Models\UsersModel ``:
2424
+ The ``$model `` property must have a child class type of Model.
2425
+
2426
+ Let's see below that ``$model `` receives the type name of the
2427
+ ``App\Models\UsersModel `` class and in the ``show `` method the direct call to
2428
+ the ``$model `` property is used, which has the instance of
2429
+ ``App\Models\UsersModel ``:
2429
2430
2430
2431
.. code-block :: php
2431
2432
@@ -2435,7 +2436,7 @@ which has the instance of ``App\Models\UsersModel``:
2435
2436
2436
2437
class Users extends Controller
2437
2438
{
2438
- protected ModelInterface | UsersModel $model;
2439
+ protected UsersModel $model;
2439
2440
2440
2441
public function show(int $id) : string
2441
2442
{
You can’t perform that action at this time.
0 commit comments