File tree Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ class Gross extends \PHPFUI\ORM\VirtualField
66 {
77 public function getValue (array $ parameters ) : mixed
88 {
9- return \number_format ($ this ->parentRecord ->unit_price * $ this ->parentRecord ->quantity - $ this ->parentRecord ->discount , 2 );
9+ return \number_format ($ this ->currentRecord ->unit_price * $ this ->currentRecord ->quantity - $ this ->currentRecord ->discount , 2 );
1010 }
1111 }
Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ public function getValue(array $parameters) : mixed
2727 $ childTable = new $ child ();
2828 $ condition = new \PHPFUI \ORM \Condition ();
2929
30- foreach ($ this ->parentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
30+ foreach ($ this ->currentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
3131 {
32- $ condition ->and ($ primaryKey , $ this ->parentRecord ->{$ primaryKey });
32+ $ condition ->and ($ primaryKey , $ this ->currentRecord ->{$ primaryKey });
3333 }
3434 $ childTable ->setWhere ($ condition );
3535
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ public function getValue(array $parameters) : mixed
3333 $ relatedTable ->addJoin ($ junctionTableName , $ relatedTableName . \PHPFUI \ORM ::$ idSuffix );
3434 $ condition = new \PHPFUI \ORM \Condition ();
3535
36- foreach ($ this ->parentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
36+ foreach ($ this ->currentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
3737 {
38- $ condition ->and ($ junctionTableName . '. ' . $ primaryKey , $ this ->parentRecord ->{$ primaryKey });
38+ $ condition ->and ($ junctionTableName . '. ' . $ primaryKey , $ this ->currentRecord ->{$ primaryKey });
3939 }
4040
4141 foreach ($ relatedTable ->getPrimaryKeys () as $ primaryKey => $ junk )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PHPFUI \ORM ;
4+
5+ class RelatedRecord extends \PHPFUI \ORM \VirtualField
6+ {
7+ public function getValue (array $ parameters ) : mixed
8+ {
9+ $ class = \array_shift ($ parameters );
10+
11+ return new $ class ($ this ->currentRecord [$ this ->fieldName . \PHPFUI \ORM ::$ idSuffix ]);
12+ }
13+ }
Original file line number Diff line number Diff line change 44
55abstract class VirtualField
66 {
7- public function __construct (protected \PHPFUI \ORM \Record $ parentRecord , protected string $ fieldName )
7+ public function __construct (protected \PHPFUI \ORM \Record $ currentRecord , protected string $ fieldName )
88 {
99 }
1010
1111 public function getValue (array $ parameters ) : mixed
1212 {
13- throw new \PHPFUI \ORM \Exception ("get not defined for {$ this ->parentRecord ->getTableName ()}. {$ this ->fieldName }" );
13+ throw new \PHPFUI \ORM \Exception ("get not defined for {$ this ->currentRecord ->getTableName ()}. {$ this ->fieldName }" );
1414 }
1515
1616 public function setValue (mixed $ value , array $ parameters ) : void
1717 {
18- throw new \PHPFUI \ORM \Exception ("set not defined for {$ this ->parentRecord ->getTableName ()}. {$ this ->fieldName }" );
18+ throw new \PHPFUI \ORM \Exception ("set not defined for {$ this ->currentRecord ->getTableName ()}. {$ this ->fieldName }" );
1919 }
2020 }
You can’t perform that action at this time.
0 commit comments