File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
tests/system/Database/Live Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1579,6 +1579,20 @@ public function errors(bool $forceDB = false)
1579
1579
return $ error ['message ' ] ?? null ;
1580
1580
}
1581
1581
1582
+ //--------------------------------------------------------------------
1583
+
1584
+ /**
1585
+ * It could be used when you have to change default or override current allowed fields.
1586
+ *
1587
+ * @param array $allowedFields
1588
+ *
1589
+ * @return void
1590
+ */
1591
+ public function setAllowedFields (array $ allowedFields )
1592
+ {
1593
+ $ this ->allowedFields = $ allowedFields ;
1594
+ }
1595
+
1582
1596
//--------------------------------------------------------------------
1583
1597
//--------------------------------------------------------------------
1584
1598
// Validation
Original file line number Diff line number Diff line change 1
- <?php namespace CodeIgniter \Database \Live ;
1
+ <?php
2
+
3
+ namespace CodeIgniter \Database \Live ;
2
4
3
5
use BadMethodCallException ;
4
6
use CodeIgniter \Config \Config ;
@@ -2579,4 +2581,27 @@ public function testcountAllResultsFalseWithDeletedFalseUseSoftDeletesFalse()
2579
2581
$ this ->assertFalse ($ this ->getPrivateProperty ($ model , 'tempUseSoftDeletes ' ));
2580
2582
}
2581
2583
2584
+ public function testSetAllowedFields ()
2585
+ {
2586
+ $ allowed1 = [
2587
+ 'id ' ,
2588
+ 'created_at ' ,
2589
+ ];
2590
+ $ allowed2 = [
2591
+ 'id ' ,
2592
+ 'updated_at ' ,
2593
+ ];
2594
+
2595
+ $ model = new class extends Model {
2596
+ protected $ allowedFields = [
2597
+ 'id ' ,
2598
+ 'created_at ' ,
2599
+ ];
2600
+ };
2601
+
2602
+ $ this ->assertSame ($ allowed1 , $ this ->getPrivateProperty ($ model , 'allowedFields ' ));
2603
+
2604
+ $ model ->setAllowedFields ($ allowed2 );
2605
+ $ this ->assertSame ($ allowed2 , $ this ->getPrivateProperty ($ model , 'allowedFields ' ));
2606
+ }
2582
2607
}
You can’t perform that action at this time.
0 commit comments