1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Currency Entity. |
4
|
|
|
* |
5
|
|
|
* @package App\Entities\Currency |
6
|
|
|
* |
7
|
|
|
* @author Nick Menke <[email protected]> |
8
|
|
|
* @copyright 2018-2020 Nick Menke |
9
|
|
|
* |
10
|
|
|
* @link https://github.com/nlmenke/vertebrae |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace App\Entities\Currency; |
16
|
|
|
|
17
|
|
|
use App\Entities\AbstractEntity; |
18
|
|
|
use App\Entities\Country\Country; |
19
|
|
|
use Illuminate\Database\Eloquent\Collection; |
20
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany; |
21
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The Currency entity class. |
25
|
|
|
* |
26
|
|
|
* This class contains any functions required to access and manipulate currency |
27
|
|
|
* models. |
28
|
|
|
* |
29
|
|
|
* @since x.x.x introduced |
30
|
|
|
*/ |
31
|
|
|
class Currency extends AbstractEntity |
32
|
|
|
{ |
33
|
|
|
use SoftDeletes; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The attributes that are mass assignable. |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $fillable = [ |
41
|
|
|
'iso_alpha', |
42
|
|
|
'iso_numeric', |
43
|
|
|
'name', |
44
|
|
|
'symbol', |
45
|
|
|
'decimal_precision', |
46
|
|
|
'exchange_rate', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The countries relationship instance. |
51
|
|
|
* |
52
|
|
|
* @return HasMany |
53
|
|
|
*/ |
54
|
4 |
|
public function countries(): HasMany |
55
|
|
|
{ |
56
|
4 |
|
return $this->hasMany(Country::class); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the countries attribute. |
61
|
|
|
* |
62
|
|
|
* @return Country[]|Collection |
63
|
|
|
*/ |
64
|
|
|
public function getCountries() |
65
|
|
|
{ |
66
|
|
|
return $this->getAttribute('countries'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get the decimal_precision attribute. |
71
|
|
|
* |
72
|
|
|
* @return int |
73
|
|
|
*/ |
74
|
|
|
public function getDecimalPrecision(): int |
75
|
|
|
{ |
76
|
|
|
return $this->getAttribute('decimal_precision'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Get the exchange_rate attribute. |
81
|
|
|
* |
82
|
|
|
* @return float |
83
|
|
|
*/ |
84
|
|
|
public function getExchangeRate(): float |
85
|
|
|
{ |
86
|
|
|
return $this->getAttribute('exchange_rate'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the iso_alpha attribute. |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getIsoAlpha(): string |
95
|
|
|
{ |
96
|
|
|
return $this->getAttribute('iso_alpha'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get the iso_numeric attribute. |
101
|
|
|
* |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
public function getIsoNumeric(): string |
105
|
|
|
{ |
106
|
|
|
return $this->getAttribute('iso_numeric'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Get the name attribute. |
111
|
|
|
* |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
|
|
public function getName(): string |
115
|
|
|
{ |
116
|
|
|
return $this->getAttribute('name'); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Get the symbol attribute. |
121
|
|
|
* |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function getSymbol(): string |
125
|
|
|
{ |
126
|
|
|
return $this->getAttribute('symbol'); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|