@@ -111,12 +111,12 @@ is used with methods like ``find()`` to know what column to match the specified
111
111
$useAutoIncrement
112
112
-----------------
113
113
114
- Specifies if the table uses an auto-increment feature for `` $primaryKey `` . If set to ``false ``
114
+ Specifies if the table uses an auto-increment feature for `$primaryKey `_ . If set to ``false ``
115
115
then you are responsible for providing primary key value for every record in the table. This
116
116
feature may be handy when we want to implement 1:1 relation or use UUIDs for our model. The
117
117
default value is ``true ``.
118
118
119
- .. note :: If you set `` $useAutoIncrement`` to ``false``, then make sure to set your primary
119
+ .. note :: If you set `$useAutoIncrement`_ to ``false``, then make sure to set your primary
120
120
key in the database to ``unique ``. This way you will make sure that all of Model's features
121
121
will still work the same as before.
122
122
@@ -142,8 +142,8 @@ part of a security trail. If true, the **find*()** methods will only return non-
142
142
the ``withDeleted() `` method is called prior to calling the **find*() ** method.
143
143
144
144
This requires either a DATETIME or INTEGER field in the database as per the model's
145
- `` $dateFormat `` setting. The default field name is ``deleted_at `` however this name can be
146
- configured to any name of your choice by using `` $deletedField `` property.
145
+ `$dateFormat `_ setting. The default field name is ``deleted_at `` however this name can be
146
+ configured to any name of your choice by using `$deletedField `_ property.
147
147
148
148
.. important :: The ``deleted_at`` field must be nullable.
149
149
@@ -155,7 +155,7 @@ This array should be updated with the field names that can be set during ``save(
155
155
against just taking input from a form and throwing it all at the model, resulting in
156
156
potential mass assignment vulnerabilities.
157
157
158
- .. note :: The `` $primaryKey`` field should never be an allowed field.
158
+ .. note :: The `$primaryKey`_ field should never be an allowed field.
159
159
160
160
Dates
161
161
-----
@@ -164,29 +164,29 @@ $useTimestamps
164
164
^^^^^^^^^^^^^^
165
165
166
166
This boolean value determines whether the current date is automatically added to all inserts
167
- and updates. If true, will set the current time in the format specified by `` $dateFormat `` . This
167
+ and updates. If `` true `` , will set the current time in the format specified by `$dateFormat `_ . This
168
168
requires that the table have columns named **created_at **, **updated_at ** and **deleted_at ** in the appropriate
169
169
data type.
170
170
171
171
$dateFormat
172
172
^^^^^^^^^^^
173
173
174
- This value works with `` $useTimestamps `` and `` $useSoftDeletes `` to ensure that the correct type of
174
+ This value works with `$useTimestamps `_ and `$useSoftDeletes `_ to ensure that the correct type of
175
175
date value gets inserted into the database. By default, this creates DATETIME values, but
176
- valid options are: ``'datetime' ``, ``'date' ``, or ``'int' `` (a PHP timestamp). Using ** useSoftDeletes ** or
177
- ** useTimestamps ** with an invalid or missing ** dateFormat ** will cause an exception.
176
+ valid options are: ``'datetime' ``, ``'date' ``, or ``'int' `` (a PHP timestamp). Using ` $ useSoftDeletes`_ or
177
+ ` $ useTimestamps`_ with an invalid or missing ` $ dateFormat`_ will cause an exception.
178
178
179
179
$createdField
180
180
^^^^^^^^^^^^^
181
181
182
182
Specifies which database field to use for data record create timestamp.
183
- Set to an empty string (``'' ``) to avoid updating it (even if `` $useTimestamps `` is enabled).
183
+ Set to an empty string (``'' ``) to avoid updating it (even if `$useTimestamps `_ is enabled).
184
184
185
185
$updatedField
186
186
^^^^^^^^^^^^^
187
187
188
188
Specifies which database field should use for keep data record update timestamp.
189
- Set to an empty string (``'' ``) to avoid updating it (even `` $useTimestamps `` is enabled).
189
+ Set to an empty string (``'' ``) to avoid updating it (even `$useTimestamps `_ is enabled).
190
190
191
191
$deletedField
192
192
^^^^^^^^^^^^^
@@ -284,7 +284,7 @@ Returns a single row where the primary key matches the value passed in as the fi
284
284
285
285
.. literalinclude :: model/006.php
286
286
287
- The value is returned in the format specified in `` $returnType `` .
287
+ The value is returned in the format specified in `$returnType `_ .
288
288
289
289
You can specify more than one row to return by passing an array of primaryKey values instead
290
290
of just one:
@@ -329,7 +329,7 @@ Returns the first row in the result set. This is best used in combination with t
329
329
withDeleted()
330
330
-------------
331
331
332
- If `` $useSoftDeletes `` is true, then the **find*() ** methods will not return any rows where ``deleted_at IS NOT NULL ``.
332
+ If `$useSoftDeletes `_ is true, then the **find*() ** methods will not return any rows where ``deleted_at IS NOT NULL ``.
333
333
To temporarily override this, you can use the ``withDeleted() `` method prior to calling the **find*() ** method.
334
334
335
335
.. literalinclude :: model/013.php
@@ -351,7 +351,7 @@ insert()
351
351
The first parameter is an associative array of data to create a new row of data in the database.
352
352
If an object is passed instead of an array, it will attempt to convert it to an array.
353
353
354
- The array's keys must match the name of the columns in the `` $table `` , while the array's values are the values to save for that key.
354
+ The array's keys must match the name of the columns in the `$table `_ , while the array's values are the values to save for that key.
355
355
356
356
The optional second parameter is of type boolean, and if it is set to false, the method will return a boolean value,
357
357
which indicates the success or failure of the query.
@@ -376,15 +376,15 @@ You can enable the check again by calling ``allowEmptyInserts(false)``.
376
376
update()
377
377
--------
378
378
379
- Updates an existing record in the database. The first parameter is the `` $primaryKey `` of the record to update.
379
+ Updates an existing record in the database. The first parameter is the `$primaryKey `_ of the record to update.
380
380
An associative array of data is passed into this method as the second parameter. The array's keys must match the name
381
- of the columns in a `` $table `` , while the array's values are the values to save for that key:
381
+ of the columns in a `$table `_ , while the array's values are the values to save for that key:
382
382
383
383
.. literalinclude :: model/016.php
384
384
385
385
.. important :: Since v4.3.0, this method raises a ``DatabaseException``
386
386
if it generates an SQL statement without a WHERE clause.
387
- In previous versions, if it is called without `` $primaryKey `` specified and
387
+ In previous versions, if it is called without `$primaryKey `_ specified and
388
388
an SQL statement was generated without a WHERE clause, the query would still
389
389
execute and all records in the table would be updated.
390
390
@@ -440,7 +440,7 @@ Takes a primary key value as the first parameter and deletes the matching record
440
440
441
441
.. literalinclude :: model/023.php
442
442
443
- If the model's `` $useSoftDeletes `` value is true, this will update the row to set ``deleted_at `` to the current
443
+ If the model's `$useSoftDeletes `_ value is true, this will update the row to set ``deleted_at `` to the current
444
444
date and time. You can force a permanent delete by setting the second parameter as true.
445
445
446
446
An array of primary keys can be passed in as the first parameter to delete multiple records at once:
@@ -481,13 +481,13 @@ prior to saving to the database with the ``insert()``, ``update()``, or ``save()
481
481
Setting Validation Rules
482
482
------------------------
483
483
484
- The first step is to fill out the `` $validationRules `` class property with the fields and rules that should
485
- be applied. If you have custom error message that you want to use, place them in the `` $validationMessages `` array:
484
+ The first step is to fill out the `$validationRules `_ class property with the fields and rules that should
485
+ be applied. If you have custom error message that you want to use, place them in the `$validationMessages `_ array:
486
486
487
487
.. literalinclude :: model/027.php
488
488
489
489
If you'd rather organize your rules and error messages within the Validation configuration file, you can do that
490
- and simply set `` $validationRules `` to the name of the validation rule group you created:
490
+ and simply set `$validationRules `_ to the name of the validation rule group you created:
491
491
492
492
.. literalinclude :: model/034.php
493
493
@@ -614,7 +614,7 @@ Protecting Fields
614
614
=================
615
615
616
616
To help protect against Mass Assignment Attacks, the Model class **requires ** that you list all of the field names
617
- that can be changed during inserts and updates in the `` $allowedFields `` class property. Any data provided
617
+ that can be changed during inserts and updates in the `$allowedFields `_ class property. Any data provided
618
618
in addition to these will be removed prior to hitting the database. This is great for ensuring that timestamps,
619
619
or primary keys do not get changed.
620
620
@@ -629,7 +629,7 @@ Runtime Return Type Changes
629
629
===========================
630
630
631
631
You can specify the format that data should be returned as when using the **find*() ** methods as the class property,
632
- `` $returnType `` . There may be times that you would like the data back in a different format, though. The Model
632
+ `$returnType `_ . There may be times that you would like the data back in a different format, though. The Model
633
633
provides methods that allow you to do just that.
634
634
635
635
.. note :: These methods only change the return type for the next **find*()** method call. After that,
@@ -674,7 +674,7 @@ You can get access to the **shared** instance of the Query Builder any time you
674
674
675
675
.. literalinclude :: model/043.php
676
676
677
- This builder is already set up with the model's `` $table `` .
677
+ This builder is already set up with the model's `$table `_ .
678
678
679
679
.. note :: Once you get the Query Builder instance, you can call methods of the
680
680
:doc: `Query Builder <../database/query_builder >`.
@@ -748,13 +748,13 @@ must return the original $data array so other callbacks have the full informatio
748
748
Specifying Callbacks To Run
749
749
===========================
750
750
751
- You specify when to run the callbacks by adding the method name to the appropriate class property (`` $beforeInsert `` , `` $afterUpdate `` ,
751
+ You specify when to run the callbacks by adding the method name to the appropriate class property (`$beforeInsert `_ , `$afterUpdate `_ ,
752
752
etc). Multiple callbacks can be added to a single event and they will be processed one after the other. You can
753
753
use the same callback in multiple events:
754
754
755
755
.. literalinclude :: model/051.php
756
756
757
- Additionally, each model may allow (default) or deny callbacks class-wide by setting its `` $allowCallbacks `` property:
757
+ Additionally, each model may allow (default) or deny callbacks class-wide by setting its `$allowCallbacks `_ property:
758
758
759
759
.. literalinclude :: model/052.php
760
760
0 commit comments