File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
system/Commands/Generators/Views
user_guide_src/source/models Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ class {class} extends Model
1717 protected $protectFields = true;
1818 protected $allowedFields = [];
1919
20+ protected bool $allowEmptyInserts = false;
21+
2022 // Dates
2123 protected $useTimestamps = false;
2224 protected $dateFormat = 'datetime';
Original file line number Diff line number Diff line change @@ -157,6 +157,17 @@ potential mass assignment vulnerabilities.
157157
158158.. note :: The `$primaryKey`_ field should never be an allowed field.
159159
160+ $allowEmptyInserts
161+ ------------------
162+
163+ .. versionadded :: 4.3.0
164+
165+ Whether to allow inserting empty data. The default value is ``false ``, meaning
166+ that if you try to insert empty data, an exception with
167+ "There is no data to insert." will raise.
168+
169+ You may also change this setting with the :ref: `model-allow-empty-inserts ` method.
170+
160171Dates
161172-----
162173
@@ -371,6 +382,8 @@ You can use ``allowEmptyInserts()`` method to insert empty data. The Model throw
371382
372383.. literalinclude :: model/056.php
373384
385+ You may also change this setting with the `$allowEmptyInserts `_ property.
386+
374387You can enable the check again by calling ``allowEmptyInserts(false) ``.
375388
376389update()
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class UserModel extends Model
1616
1717 protected $ allowedFields = ['name ' , 'email ' ];
1818
19+ protected bool $ allowEmptyInserts = false ;
20+
1921 // Dates
2022 protected $ useTimestamps = false ;
2123 protected $ dateFormat = 'datetime ' ;
You can’t perform that action at this time.
0 commit comments