Test Failed
Push — master ( 67d6ff...f8d747 )
by Gianluca
16:33
created

Category::configuration_fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Mongi\Mongicommerce\Models;
5
6
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
use Illuminate\Database\Eloquent\Model;
9
10
class Category extends Model
11
{
12
    use HasFactory;
13
14
    // Disable Laravel's mass assignment protection
15
    protected $guarded = [];
16
17
    public function parent()
18
    {
19
        return $this->belongsTo(Category::class, 'parent_id');
20
    }
21
22
    public function children_rec()
23
    {
24
        return $this->hasMany(Category::class, 'parent_id');
25
    }
26
27
    public function children()
28
    {
29
        return $this->children_rec()->with('children');
30
    }
31
32
    public function configuration_fields(){
33
        return $this->hasMany(ConfigurationField::class);
34
    }
35
36
}
37