Issues (193)

src/Models/AbstractModels/HasPurchaseParent.php (2 issues)

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
The property amount does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
        $this->currency = $payment->getPurchaseCurrency();
0 ignored issues
show
Bug Best Practice introduced by
The property currency does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
23
        return $this;
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    protected function getPurchaseFk()
30
    {
31
        return 'id_purchase';
32
    }
33
}
34