ByTIC /
payments
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ByTIC\Payments\Models\AbstractModels; |
||
| 4 | |||
| 5 | use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Trait HasPurchaseParent |
||
| 9 | * @package ByTIC\Payments\Models\AbstractModels |
||
| 10 | */ |
||
| 11 | trait HasPurchaseParent |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param IsPurchasableModelTrait $payment |
||
| 15 | * @return $this |
||
| 16 | */ |
||
| 17 | public function populateFromPayment($payment) |
||
| 18 | { |
||
| 19 | $this->{$this->getPurchaseFk()} = $payment->id; |
||
| 20 | $this->amount = floor($payment->getPurchaseAmount() * 100); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 21 | $this->currency = $payment->getPurchaseCurrency(); |
||
|
0 ignored issues
–
show
|
|||
| 22 | |||
| 23 | return $this; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | protected function getPurchaseFk() |
||
| 30 | { |
||
| 31 | return 'id_purchase'; |
||
| 32 | } |
||
| 33 | } |
||
| 34 |