Passed
Push — master ( e61f9b...d0aed5 )
by Richard
04:05
created

Rate::country()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 = ['deleted_at'];
36
37
    /**
38
     * The attributes that can be filled.
39
     *
40
     * @var string[]
41
     */
42
    public $fillable = [
43
        'rate',
44
        'name',
45
        'compound',
46
        'shipping',
47
        'type',
48
    ];
49
50
    /**
51
     * The attributes that should be casted to native types.
52
     *
53
     * @var array
54
     */
55
    protected $casts = [
56
        'rate' => 'float',
57
        'name' => 'string',
58
        'compound' => 'boolean',
59
        'shipping' => 'boolean',
60
    ];
61
62
    /**
63
     * Validation rules.
64
     *
65
     * @var array
66
     */
67
    public static $rules = [
68
        'rate' => 'required',
69
        'name' => 'required',
70
        'type' => 'required',
71
    ];
72
73
    /**
74
     * Constructor.
75
     *
76
     * @param array $attributes additional attributes for model initialisation
77
     *
78
     * @return void
79
     */
80
    public function __construct(array $attributes = [])
81
    {
82
        parent::__construct($attributes);
83
84
        $this->setTable(config('pwweb.localisation.table_names.tax.rates'));
85
    }
86
87
    /**
88
     * Accessor for linked Location model.
89
     *
90
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
91
     **/
92
    public function country(): HasMany
93
    {
94
        return $this->hasMany(\PWWEB\Localisation\Models\Tax\Location::class, 'rate_id');
95
    }
96
}
97