1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Recca0120\LaravelPayum\Model; |
4
|
|
|
|
5
|
|
|
use Payum\Core\Security\Util\Random; |
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
7
|
|
|
use Payum\Core\Security\TokenInterface; |
8
|
|
|
|
9
|
|
|
class Token extends Model implements TokenInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* $incrementing. |
13
|
|
|
* |
14
|
|
|
* @var bool |
15
|
|
|
*/ |
16
|
|
|
public $incrementing = false; |
17
|
|
|
/** |
18
|
|
|
* $table. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $table = 'payum_tokens'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* $primaryKey. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $primaryKey = 'hash'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* $unguarded. |
33
|
|
|
* |
34
|
|
|
* @var bool |
35
|
|
|
*/ |
36
|
|
|
protected static $unguarded = true; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* __construct. |
40
|
|
|
* |
41
|
|
|
* @param array $attributes |
42
|
|
|
*/ |
43
|
5 |
|
public function __construct(array $attributes = []) |
44
|
|
|
{ |
45
|
5 |
|
$attributes['hash'] = empty($attributes['hash']) === true ? Random::generateToken() : $attributes['hash']; |
46
|
5 |
|
parent::__construct($attributes); |
47
|
5 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* getHash. |
51
|
|
|
* |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
1 |
|
public function getHash() |
55
|
|
|
{ |
56
|
1 |
|
return $this->getAttribute('hash'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* setHash. |
61
|
|
|
* |
62
|
|
|
* @param string $hash |
63
|
|
|
*/ |
64
|
1 |
|
public function setHash($hash) |
65
|
|
|
{ |
66
|
1 |
|
$this->setAttribute('hash', $hash); |
67
|
1 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* setDetails. |
71
|
|
|
* |
72
|
|
|
* @param mixed $details |
73
|
|
|
*/ |
74
|
1 |
|
public function setDetails($details) |
75
|
|
|
{ |
76
|
1 |
|
$this->setAttribute('details', serialize($details)); |
77
|
1 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* getDetails. |
81
|
|
|
* |
82
|
|
|
* @return mixed |
83
|
|
|
*/ |
84
|
1 |
|
public function getDetails() |
85
|
|
|
{ |
86
|
1 |
|
return unserialize($this->getAttribute('details')); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* getTargetUrl. |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
1 |
|
public function getTargetUrl() |
95
|
|
|
{ |
96
|
1 |
|
return $this->getAttribute('targetUrl'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* setTargetUrl. |
101
|
|
|
* |
102
|
|
|
* @param string $targetUrl |
103
|
|
|
*/ |
104
|
1 |
|
public function setTargetUrl($targetUrl) |
105
|
|
|
{ |
106
|
1 |
|
$this->setAttribute('targetUrl', $targetUrl); |
107
|
1 |
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* getAfterUrl. |
111
|
|
|
* |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
1 |
|
public function getAfterUrl() |
115
|
|
|
{ |
116
|
1 |
|
return $this->getAttribute('afterUrl'); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* setAfterUrl. |
121
|
|
|
* |
122
|
|
|
* @param string $afterUrl |
123
|
|
|
*/ |
124
|
1 |
|
public function setAfterUrl($afterUrl) |
125
|
|
|
{ |
126
|
1 |
|
$this->setAttribute('afterUrl', $afterUrl); |
127
|
1 |
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* getGatewayName. |
131
|
|
|
* |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
1 |
|
public function getGatewayName() |
135
|
|
|
{ |
136
|
1 |
|
return $this->getAttribute('gatewayName'); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* setGatewayName. |
141
|
|
|
* |
142
|
|
|
* @param string $gatewayName |
143
|
|
|
*/ |
144
|
1 |
|
public function setGatewayName($gatewayName) |
145
|
|
|
{ |
146
|
1 |
|
$this->setAttribute('gatewayName', $gatewayName); |
147
|
1 |
|
} |
148
|
|
|
} |
149
|
|
|
|