TranslationModel::setLocaleKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Laraplus\Data;
4
5
use Illuminate\Database\Eloquent\Model as Eloquent;
6
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
7
8
class TranslationModel extends Eloquent
9
{
10
    /**
11
     * Translation model does not include timestamps by default.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * Name of the table (will be set dynamically).
19
     *
20
     * @var string
21
     */
22
    protected $table = null;
23
24
    /**
25
     * Indicates if the IDs are auto-incrementing.
26
     *
27
     * @var bool
28
     */
29
    public $incrementing = false;
30
31
    /**
32
     * Locale key name.
33
     *
34
     * @var string
35
     */
36
    protected $localeKey = 'locale';
37
38
    /**
39
     * Set the keys for a save update query.
40
     *
41
     * @param EloquentBuilder $query
42
     *
43
     * @return EloquentBuilder
44
     */
45
    protected function setKeysForSaveQuery(EloquentBuilder $query)
46
    {
47
        $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());
48
        $query->where($this->localeKey, '=', $this->{$this->localeKey});
49
50
        return $query;
51
    }
52
53
    /**
54
     * Set the locale key.
55
     *
56
     * @param $localeKey
57
     *
58
     * @return $this
59
     */
60
    public function setLocaleKey($localeKey)
61
    {
62
        $this->localeKey = $localeKey;
63
64
        return $this;
65
    }
66
}
67