File tree 5 files changed +21
-8
lines changed
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
6
6
{
7
7
public function getValue (array $ parameters ) : mixed
8
8
{
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 );
10
10
}
11
11
}
Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ public function getValue(array $parameters) : mixed
27
27
$ childTable = new $ child ();
28
28
$ condition = new \PHPFUI \ORM \Condition ();
29
29
30
- foreach ($ this ->parentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
30
+ foreach ($ this ->currentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
31
31
{
32
- $ condition ->and ($ primaryKey , $ this ->parentRecord ->{$ primaryKey });
32
+ $ condition ->and ($ primaryKey , $ this ->currentRecord ->{$ primaryKey });
33
33
}
34
34
$ childTable ->setWhere ($ condition );
35
35
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ public function getValue(array $parameters) : mixed
33
33
$ relatedTable ->addJoin ($ junctionTableName , $ relatedTableName . \PHPFUI \ORM ::$ idSuffix );
34
34
$ condition = new \PHPFUI \ORM \Condition ();
35
35
36
- foreach ($ this ->parentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
36
+ foreach ($ this ->currentRecord ->getPrimaryKeys () as $ primaryKey => $ junk )
37
37
{
38
- $ condition ->and ($ junctionTableName . '. ' . $ primaryKey , $ this ->parentRecord ->{$ primaryKey });
38
+ $ condition ->and ($ junctionTableName . '. ' . $ primaryKey , $ this ->currentRecord ->{$ primaryKey });
39
39
}
40
40
41
41
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 4
4
5
5
abstract class VirtualField
6
6
{
7
- public function __construct (protected \PHPFUI \ORM \Record $ parentRecord , protected string $ fieldName )
7
+ public function __construct (protected \PHPFUI \ORM \Record $ currentRecord , protected string $ fieldName )
8
8
{
9
9
}
10
10
11
11
public function getValue (array $ parameters ) : mixed
12
12
{
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 }" );
14
14
}
15
15
16
16
public function setValue (mixed $ value , array $ parameters ) : void
17
17
{
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 }" );
19
19
}
20
20
}
You can’t perform that action at this time.
0 commit comments