Completed
Push — development ( a928ed...ed05a0 )
by Claudio
02:29
created

PaymentMethod::getDisclaimerRequiredAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
use Sofa\Eloquence\Eloquence;
6
use Sofa\Eloquence\Mappable;
7
8
/**
9
 * Class PaymentMethod
10
 * @package App\Models
11
 */
12
class PaymentMethod extends ChocolateyModel
13
{
14
    use Eloquence, Mappable;
15
16
    /**
17
     * Disable Timestamps
18
     *
19
     * @var bool
20
     */
21
    public $timestamps = false;
22
23
    /**
24
     * Purchase Params
25
     *
26
     * @var PurchaseParam
27
     */
28
    public $purchaseParams = null;
29
30
    /**
31
     * The table associated with the model.
32
     *
33
     * @var string
34
     */
35
    protected $table = 'chocolatey_shop_payment_methods';
36
37
    /**
38
     * Primary Key of the Table
39
     *
40
     * @var string
41
     */
42
    protected $primaryKey = 'id';
43
44
    /**
45
     * The Appender(s) of the Model
46
     *
47
     * @var array
48
     */
49
    protected $appends = [
50
        'disclaimerRequired',
51
        'premiumSms',
52
        'purchaseParams',
53
        'requestPath'
54
    ];
55
56
    /**
57
     * The attributes excluded from the model's JSON form.
58
     *
59
     * @var array
60
     */
61
    protected $hidden = [
62
        'disclaimer'
63
    ];
64
65
    /**
66
     * The attributes that will be mapped
67
     *
68
     * @var array
69
     */
70
    protected $maps = [
71
        'disclaimerRequired' => 'disclaimer'
72
    ];
73
74
    /**
75
     * Store an Shop Country
76
     * @param string $methodName
77
     * @param string $code
78
     * @param string $buttonImageUrl
79
     * @param string $buttonText
80
     * @return PaymentMethod
81
     */
82
    public function store(string $methodName, string $code, string $buttonImageUrl, string $buttonText): PaymentMethod
83
    {
84
        $this->attributes['name'] = $methodName;
85
        $this->attributes['buttonLogoUrl'] = $buttonImageUrl;
86
        $this->attributes['buttonText'] = $buttonText;
87
        $this->attributes['localizationKey'] = $code;
88
89
        return $this;
90
    }
91
92
    /**
93
     * Get Disclaimer Required Attribute
94
     *
95
     * @return bool
96
     */
97
    public function getDisclaimerRequiredAttribute(): bool
98
    {
99
        return $this->attributes['disclaimer'] == 1;
100
    }
101
102
    /**
103
     * Get Premium SMS Attribute
104
     *
105
     * @return bool
106
     */
107
    public function getPremiumSmsAttribute(): bool
108
    {
109
        return false;
110
    }
111
112
    /**
113
     * Get Request Path Attribute
114
     *
115
     * @return string
116
     */
117
    public function getRequestPathAttribute(): string
118
    {
119
        return 'online';
120
    }
121
122
    /**
123
     * Get the Purchase Params
124
     *
125
     * @return PurchaseParam
126
     */
127
    public function getPurchaseParamsAttribute(): PurchaseParam
128
    {
129
        return $this->purchaseParams;
130
    }
131
132
    /**
133
     * Set Purchase Params
134
     * @param array $parameters
135
     */
136
    public function setPurchaseParams(array $parameters)
137
    {
138
        $this->purchaseParams = new PurchaseParam($parameters[0], $parameters[1], $this->attributes['id']);
139
    }
140
141
    /**
142
     * Get Category Payment Type
143
     *
144
     * @return string
145
     */
146
    public function getCategoryAttribute(): string
147
    {
148
        return PaymentCategory::find($this->attributes['category'])->payment_type;
149
    }
150
}
151