|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Models\Subscriptions; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasCustomer\HasCustomerRepository; |
|
6
|
|
|
use ByTIC\Payments\Utility\PaymentsModels; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Trait SubscriptionsTrait |
|
10
|
|
|
* @package ByTIC\Payments\Models\Subscriptions |
|
11
|
|
|
* |
|
12
|
|
|
* @method SubscriptionTrait|Subscription getNew |
|
13
|
|
|
*/ |
|
14
|
|
|
trait SubscriptionsTrait |
|
15
|
|
|
{ |
|
16
|
|
|
use HasCustomerRepository; |
|
17
|
|
|
use \ByTIC\Models\SmartProperties\RecordsTraits\HasStatus\RecordsTrait; |
|
18
|
|
|
|
|
19
|
|
|
protected function initRelations() |
|
20
|
|
|
{ |
|
21
|
|
|
parent::initRelations(); |
|
22
|
|
|
$this->initRelationsPayments(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
protected function initRelationsPayments() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->initRelationsTransactions(); |
|
28
|
|
|
$this->initRelationsLastTransaction(); |
|
29
|
|
|
$this->initRelationsToken(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
protected function initRelationsTransactions() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->hasMany('Transactions', ['class' => get_class(PaymentsModels::transactions())]); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
protected function initRelationsLastTransaction() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->hasOne('LastTransaction', ['class' => get_class(PaymentsModels::transactions())]); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
protected function initRelationsToken() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->hasMany('Token', ['class' => get_class(PaymentsModels::tokens())]); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getStatusItemsRootNamespace() |
|
51
|
|
|
{ |
|
52
|
|
|
return 'ByTIC\Payments\Subscriptions\Statuses\\'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getStatusItemsDirectory() |
|
59
|
|
|
{ |
|
60
|
|
|
return dirname(dirname(__DIR__)) |
|
61
|
|
|
. DIRECTORY_SEPARATOR . 'Subscriptions' |
|
62
|
|
|
. DIRECTORY_SEPARATOR . 'Statuses'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return mixed|\Nip\Config\Config |
|
67
|
|
|
* @throws \Exception |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function generateTable() |
|
70
|
|
|
{ |
|
71
|
|
|
return config('payments.tables.subscriptions', Subscriptions::TABLE); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|