Translation::scopeByElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php namespace Distilleries\Expendable\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
5
class Translation extends BaseModel {
6
7
    protected $fillable = [
8
        'iso',
9
        'id_element',
10
        'model',
11
        'id_source'
12
    ];
13
14
    /**
15
     * Get the name of the "iso" column.
16
     *
17
     * @return string
18
     */
19
    public function getIsoColumn()
20
    {
21
        return 'iso';
22
    }
23
24
    /**
25
     * Get the name of the "id_element" column.
26
     *
27
     * @return string
28
     */
29
    public function getIdElementColumn()
30
    {
31
        return 'id_element';
32
    }
33
34
    /**
35
     * Get the name of the "id_element" column.
36
     *
37
     * @return string
38
     */
39
    public function getIdSourceColumn()
40
    {
41
        return 'id_source';
42
    }
43
44
    /**
45
     * Get the name of the "model" column.
46
     *
47
     * @return string
48
     */
49
    public function getModelColumn()
50
    {
51
        return 'model';
52
    }
53
54
    public function scopeByElement($query, Model $model)
55
    {
56
        return $query->where($this->getTable() . '.' . $this->getModelColumn(), '=', $model->getTable())
57
                        ->where($this->getTable() . '.' . $this->getIdSourceColumn(), '=', $model->getKey());
58
    }
59
60
}
61