1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use Backpack\CRUD\app\Models\Traits\CrudTrait; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | |||
8 | /** |
||
9 | * @mixin IdeHelperFee |
||
10 | */ |
||
11 | class Fee extends Model |
||
12 | { |
||
13 | use CrudTrait; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
14 | |||
15 | public $timestamps = false; |
||
16 | |||
17 | protected $guarded = ['id']; |
||
18 | |||
19 | protected $appends = ['price_with_currency', 'type']; |
||
20 | |||
21 | /* |
||
22 | |-------------------------------------------------------------------------- |
||
23 | | FUNCTIONS |
||
24 | |-------------------------------------------------------------------------- |
||
25 | */ |
||
26 | |||
27 | /* |
||
28 | |-------------------------------------------------------------------------- |
||
29 | | RELATIONS |
||
30 | |-------------------------------------------------------------------------- |
||
31 | */ |
||
32 | |||
33 | /* |
||
34 | |-------------------------------------------------------------------------- |
||
35 | | SCOPES |
||
36 | |-------------------------------------------------------------------------- |
||
37 | */ |
||
38 | |||
39 | /* |
||
40 | |-------------------------------------------------------------------------- |
||
41 | | ACCESORS |
||
42 | |-------------------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | public function getPriceAttribute($value) |
||
46 | { |
||
47 | return $value / 100; |
||
48 | } |
||
49 | |||
50 | public function getPriceWithCurrencyAttribute() |
||
51 | { |
||
52 | if (config('app.currency_position') === 'before') { |
||
53 | return config('app.currency_symbol').' '.$this->price; |
||
54 | } |
||
55 | |||
56 | return $this->price.' '.config('app.currency_symbol'); |
||
57 | } |
||
58 | |||
59 | public function getTypeAttribute() |
||
60 | { |
||
61 | return 'fee'; |
||
62 | } |
||
63 | |||
64 | /* |
||
65 | |-------------------------------------------------------------------------- |
||
66 | | MUTATORS |
||
67 | |-------------------------------------------------------------------------- |
||
68 | */ |
||
69 | |||
70 | public function setPriceAttribute($value) |
||
71 | { |
||
72 | $this->attributes['price'] = $value * 100; |
||
73 | } |
||
74 | } |
||
75 |