Completed
Push — master ( 6f54d6...ffe8b5 )
by CodexShaper
05:45
created

MenuItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 22
ccs 0
cts 11
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A children() 0 3 1
A childrens() 0 3 1
A settings() 0 3 1
1
<?php
2
3
namespace CodexShaper\DBM\Models;
4
5
use CodexShaper\DBM\Models\MenuSetting;
0 ignored issues
show
Bug introduced by
The type CodexShaper\DBM\Models\MenuSetting was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Database\Eloquent\Model;
7
8
class MenuItem extends Model
9
{
10
    protected $table = 'menu_items';
11
    //
12
    protected $fillable = [
13
        'title', 'slug', 'order', 'parent_id',
14
    ];
15
16
    public function children()
17
    {
18
        return $this->hasMany(MenuItem::class, 'parent_id')->orderBy('order', 'asc');
19
    }
20
21
    // recursive, loads all descendants
22
    public function childrens()
23
    {
24
        return $this->children()->with('childrens');
25
    }
26
27
    public function settings()
28
    {
29
        return $this->hasMany(MenuSetting::class, 'menu_id');
30
    }
31
}
32