|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tzsk\Payu\Concerns; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Validator; |
|
6
|
|
|
use Illuminate\Validation\ValidationException; |
|
7
|
|
|
use Tzsk\Payu\Contracts\HasFormParams; |
|
8
|
|
|
|
|
9
|
|
|
class Attributes implements HasFormParams |
|
10
|
|
|
{ |
|
11
|
|
|
public ?string $udf1 = null; |
|
|
|
|
|
|
12
|
|
|
public ?string $udf2 = null; |
|
13
|
|
|
public ?string $udf3 = null; |
|
14
|
|
|
public ?string $udf4 = null; |
|
15
|
|
|
public ?string $udf5 = null; |
|
16
|
|
|
public ?string $udf6 = null; |
|
17
|
|
|
public ?string $udf7 = null; |
|
18
|
|
|
public ?string $udf8 = null; |
|
19
|
|
|
public ?string $udf9 = null; |
|
20
|
|
|
public ?string $udf10 = null; |
|
21
|
|
|
|
|
22
|
|
|
public static function make() |
|
23
|
|
|
{ |
|
24
|
|
|
return new self(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function udf1(string $udf1): self |
|
28
|
|
|
{ |
|
29
|
|
|
$this->udf1 = $udf1; |
|
30
|
|
|
|
|
31
|
|
|
return $this; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function udf2(string $udf2): self |
|
35
|
|
|
{ |
|
36
|
|
|
$this->udf2 = $udf2; |
|
37
|
|
|
|
|
38
|
|
|
return $this; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function udf3(string $udf3): self |
|
42
|
|
|
{ |
|
43
|
|
|
$this->udf3 = $udf3; |
|
44
|
|
|
|
|
45
|
|
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function udf4(string $udf4): self |
|
49
|
|
|
{ |
|
50
|
|
|
$this->udf4 = $udf4; |
|
51
|
|
|
|
|
52
|
|
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function udf5(string $udf5): self |
|
56
|
|
|
{ |
|
57
|
|
|
$this->udf5 = $udf5; |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function udf6(string $udf6): self |
|
63
|
|
|
{ |
|
64
|
|
|
$this->udf6 = $udf6; |
|
65
|
|
|
|
|
66
|
|
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function udf7(string $udf7): self |
|
70
|
|
|
{ |
|
71
|
|
|
$this->udf7 = $udf7; |
|
72
|
|
|
|
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function udf8(string $udf8): self |
|
77
|
|
|
{ |
|
78
|
|
|
$this->udf8 = $udf8; |
|
79
|
|
|
|
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function udf9(string $udf9): self |
|
84
|
|
|
{ |
|
85
|
|
|
$this->udf9 = $udf9; |
|
86
|
|
|
|
|
87
|
|
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function udf10(string $udf10): self |
|
91
|
|
|
{ |
|
92
|
|
|
$this->udf10 = $udf10; |
|
93
|
|
|
|
|
94
|
|
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function toArray(): array |
|
98
|
|
|
{ |
|
99
|
|
|
return [ |
|
100
|
|
|
'udf1' => $this->udf1, |
|
101
|
|
|
'udf2' => $this->udf2, |
|
102
|
|
|
'udf3' => $this->udf3, |
|
103
|
|
|
'udf4' => $this->udf4, |
|
104
|
|
|
'udf5' => $this->udf5, |
|
105
|
|
|
'udf6' => $this->udf6, |
|
106
|
|
|
'udf7' => $this->udf7, |
|
107
|
|
|
'udf8' => $this->udf8, |
|
108
|
|
|
'udf9' => $this->udf9, |
|
109
|
|
|
'udf10' => $this->udf10, |
|
110
|
|
|
]; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @throws ValidationException |
|
115
|
|
|
*/ |
|
116
|
|
|
public function validate(): array |
|
117
|
|
|
{ |
|
118
|
|
|
return Validator::make($this->toArray(), [ |
|
119
|
|
|
'udf1' => 'nullable|string', |
|
120
|
|
|
'udf2' => 'nullable|string', |
|
121
|
|
|
'udf3' => 'nullable|string', |
|
122
|
|
|
'udf4' => 'nullable|string', |
|
123
|
|
|
'udf5' => 'nullable|string', |
|
124
|
|
|
'udf6' => 'nullable|string', |
|
125
|
|
|
'udf7' => 'nullable|string', |
|
126
|
|
|
'udf8' => 'nullable|string', |
|
127
|
|
|
'udf9' => 'nullable|string', |
|
128
|
|
|
'udf10' => 'nullable|string', |
|
129
|
|
|
])->validate(); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function fields(): array |
|
133
|
|
|
{ |
|
134
|
|
|
return array_filter($this->toArray()); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|