1 | <?php |
||
13 | trait AttributesMassAssignable |
||
14 | { |
||
15 | /** |
||
16 | * This method is used to mass assign the properties required in a class. |
||
17 | * |
||
18 | * It loops through the fields marked as required and optional |
||
19 | * and then assisngs values to those fields using accessors |
||
20 | * available in the class for those required options. |
||
21 | * |
||
22 | * @param array $data |
||
23 | * @example [ |
||
24 | * 'walletId' => 'some-existing-walletId', |
||
25 | * 'transactionId' => 'someExistingTransactionId' |
||
26 | * ] |
||
27 | * @return static |
||
28 | */ |
||
29 | protected function massAssignAttributes($data = []) |
||
47 | |||
48 | /** |
||
49 | * Assign static variables in a dynamic way |
||
50 | * |
||
51 | * @param array $data |
||
52 | * @return void |
||
53 | */ |
||
54 | // public static function massAssignStaticAttributes($data = []) |
||
55 | // { |
||
56 | // if (is_array($data)) { |
||
57 | // foreach ($data as $key => $value) { |
||
58 | // if (method_exists($this, 'set' . $key) |
||
59 | // && in_array($key, array_merge($this->parametersRequired, $this->parametersOptional)) |
||
60 | // ) { |
||
61 | // self::$key = $value; |
||
62 | // } |
||
63 | // } |
||
64 | // } |
||
65 | |||
66 | // } |
||
67 | } |
||
68 |