Completed
Push — master ( 87ffc7...2cce3d )
by Nicolas
02:37
created

Page   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 51
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 15 2
1
<?php namespace Modules\Page\Entities;
2
3
use Dimsav\Translatable\Translatable;
4
use Illuminate\Database\Eloquent\Model;
5
6
class Page extends Model
7
{
8
    use Translatable;
9
10
    protected $table = 'page__pages';
11
    public $translatedAttributes = [
12
        'page_id',
13
        'title',
14
        'slug',
15
        'status',
16
        'body',
17
        'meta_title',
18
        'meta_description',
19
        'og_title',
20
        'og_description',
21
        'og_image',
22
        'og_type',
23
    ];
24
    protected $fillable = [
25
        'is_home',
26
        'template',
27
        // Translatable fields
28
        'page_id',
29
        'title',
30
        'slug',
31
        'status',
32
        'body',
33
        'meta_title',
34
        'meta_description',
35
        'og_title',
36
        'og_description',
37
        'og_image',
38
        'og_type',
39
    ];
40
41
    public function __call($method, $parameters)
42
    {
43
        #i: Convert array to dot notation
44
        $config = implode('.', ['asgard.page.config.relations', $method]);
45
46
        #i: Relation method resolver
47
        if (config()->has($config)) {
48
            $function = config()->get($config);
49
50
            return $function($this);
51
        }
52
53
        #i: No relation found, return the call to parent (Eloquent) to handle it.
54
        return parent::__call($method, $parameters);
55
    }
56
}
57