DictOption   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 17
c 1
b 0
f 0
dl 0
loc 52
ccs 0
cts 2
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A dict() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GarbuzIvan\LaravelGeneratorPackage\Models;
6
7
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
8
use Illuminate\Database\Eloquent\Factories\HasFactory;
9
use Illuminate\Database\Eloquent\Model;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11
12
class DictOption extends Model
13
{
14
    use HasFactory;
15
16
    protected $table = 'lgp_dict_option';
17
18
    /**
19
     * @var array
20
     */
21
    protected $fillable = [
22
        'name',
23
        'json',
24
        'dict_id',
25
    ];
26
27
    /**
28
     * The attributes that should be hidden for arrays.
29
     *
30
     * @var array
31
     */
32
    protected $hidden = [];
33
34
    /**
35
     * The attributes that should be casted to native types.
36
     *
37
     * @var array
38
     */
39
    protected $casts = [
40
        'id' => 'integer',
41
        'name' => 'string',
42
        'json' => AsArrayObject::class,
43
        'dict_id' => 'integer',
44
    ];
45
46
    /**
47
     * Validation rules
48
     *
49
     * @var array
50
     */
51
    public static $rules = [
52
        'name' => 'required',
53
        'dict_id' => 'required',
54
    ];
55
56
    /**
57
     * Get dict for option
58
     *
59
     * @return BelongsTo
60
     */
61
    public function dict(): BelongsTo
62
    {
63
        return $this->belongsTo(Dict::class, 'id', 'dict_id');
64
    }
65
}
66