1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Models\Subscriptions; |
4
|
|
|
|
5
|
|
|
use ByTIC\DataObjects\Behaviors\Timestampable\TimestampableTrait; |
6
|
|
|
use ByTIC\DataObjects\Casts\Metadata\AsMetadataObject; |
7
|
|
|
use ByTIC\Omnipay\Common\Models\SubscriptionInterface; |
|
|
|
|
8
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasCustomer\HasCustomerRecord; |
9
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasPaymentMethod\HasPaymentMethodRecordTrait; |
10
|
|
|
use ByTIC\Payments\Models\Tokens\Token; |
11
|
|
|
use ByTIC\Payments\Models\Transactions\Transaction; |
12
|
|
|
use ByTIC\Payments\Models\Transactions\TransactionTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Trait SubscriptionTrait |
16
|
|
|
* @package ByTIC\Payments\Models\Subscriptions |
17
|
|
|
* |
18
|
|
|
* @property int $id_method |
19
|
|
|
* @property int $id_token |
20
|
|
|
* @property int $id_last_transaction |
21
|
|
|
* @property int $id_billing_record |
22
|
|
|
* |
23
|
|
|
* @property string $billing_period |
24
|
|
|
* @property int $billing_interval |
25
|
|
|
* @property int $billing_count |
26
|
|
|
* |
27
|
|
|
* @property string $start_at |
28
|
|
|
* @property string $cancel_at |
29
|
|
|
* @property string $ended_at |
30
|
|
|
* @property string $charge_at |
31
|
|
|
* |
32
|
|
|
* @property string $modified |
33
|
|
|
* @property string $created |
34
|
|
|
* |
35
|
|
|
* @method SubscriptionsTrait getManager |
36
|
|
|
*/ |
37
|
|
|
trait SubscriptionTrait |
38
|
|
|
{ |
39
|
|
|
use \ByTIC\Models\SmartProperties\RecordsTraits\HasStatus\RecordTrait; |
40
|
|
|
use HasPaymentMethodRecordTrait; |
41
|
|
|
use HasCustomerRecord; |
42
|
|
|
use TimestampableTrait; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
static protected $createTimestamps = ['created']; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
static protected $updateTimestamps = ['modified']; |
53
|
|
|
|
54
|
|
|
public function bootSubscriptionTrait() |
55
|
|
|
{ |
56
|
|
|
$fields = ['start_at', 'cancel_at', 'ended_at', 'charge_at']; |
57
|
|
|
foreach ($fields as $field) { |
58
|
|
|
if ($this->hasCast($field)) { |
|
|
|
|
59
|
|
|
continue; |
60
|
|
|
} |
61
|
|
|
$this->addCast($field, 'datetime'); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
$this->addCast('metadata', AsMetadataObject::class . ':json'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param $key |
68
|
|
|
* @param $value |
69
|
|
|
*/ |
70
|
|
|
public function addMedata($key, $value) |
71
|
|
|
{ |
72
|
|
|
$this->metadata->set($key, $value); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param Transaction|TransactionTrait $transaction |
77
|
|
|
*/ |
78
|
|
|
public function populateFromLastTransaction($transaction) |
79
|
|
|
{ |
80
|
|
|
$this->id_last_transaction = $transaction->id; |
81
|
|
|
$this->getRelation('LastTransaction')->setResults($transaction); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param Token $token |
86
|
|
|
*/ |
87
|
|
|
public function populateFromToken($token) |
88
|
|
|
{ |
89
|
|
|
$this->id_token = $token->id; |
90
|
|
|
$this->getRelation('Token')->setResults($token); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths