Rate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 23
c 2
b 0
f 0
dl 0
loc 72
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A country() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace PWWEB\Localisation\Models\Tax;
4
5
use Eloquent as Model;
6
use Illuminate\Database\Eloquent\Relations\HasMany;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
use PWWEB\Core\Traits\Migratable;
9
10
/**
11
 * PWWEB\Localisation\Models\Tax\Rate Model.
12
 *
13
 * Standard Rate Model.
14
 *
15
 * @author    Frank Pillukeit <[email protected]>
16
 * @author    Richard Browne <[email protected]
17
 * @copyright 2020 pw-websolutions.com
18
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
19
 * @property  number rate
20
 * @property  string name
21
 * @property  bool compound
22
 * @property  bool shipping
23
 * @property  int type
24
 */
25
class Rate extends Model
26
{
27
    use Migratable;
28
    use SoftDeletes;
29
30
    /**
31
     * The attributes that should be casted to Carbon dates.
32
     *
33
     * @var string[]
34
     */
35
    protected $dates = [
36
        'deleted_at',
37
    ];
38
39
    /**
40
     * The attributes that can be filled.
41
     *
42
     * @var string[]
43
     */
44
    public $fillable = [
45
        'rate',
46
        'name',
47
        'compound',
48
        'shipping',
49
        'type',
50
    ];
51
52
    /**
53
     * The attributes that should be casted to native types.
54
     *
55
     * @var array
56
     */
57
    protected $casts = [
58
        'rate' => 'float',
59
        'name' => 'string',
60
        'compound' => 'boolean',
61
        'shipping' => 'boolean',
62
    ];
63
64
    /**
65
     * Validation rules.
66
     *
67
     * @var array
68
     */
69
    public static $rules = [
70
        'rate' => 'required',
71
        'name' => 'required',
72
        'type' => 'required',
73
    ];
74
75
    /**
76
     * Constructor.
77
     *
78
     * @param array $attributes additional attributes for model initialisation
79
     *
80
     * @return void
81
     */
82
    public function __construct(array $attributes = [])
83
    {
84
        parent::__construct($attributes);
85
86
        $this->setTable(config('pwweb.localisation.table_names.tax.rates'));
87
    }
88
89
    /**
90
     * Accessor for linked Location model.
91
     *
92
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
93
     **/
94
    public function country(): HasMany
95
    {
96
        return $this->hasMany(config('pwweb.localisation.table_names.tax.location'), 'rate_id');
97
    }
98
}
99