Completed
Pull Request — master (#25)
by
unknown
04:29 queued 01:45
created

Page   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 54
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
    protected $casts = [
41
        'is_home' => 'boolean',
42
    ];
43
44
    public function __call($method, $parameters)
45
    {
46
        #i: Convert array to dot notation
47
        $config = implode('.', ['asgard.page.config.relations', $method]);
48
49
        #i: Relation method resolver
50
        if (config()->has($config)) {
51
            $function = config()->get($config);
52
53
            return $function($this);
54
        }
55
56
        #i: No relation found, return the call to parent (Eloquent) to handle it.
57
        return parent::__call($method, $parameters);
58
    }
59
}
60