Completed
Push — master ( cffbd7...3e7360 )
by Dimitrios
21s
created

Person::getNameAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Dimsav\Translatable\Test\Model;
4
5
use Dimsav\Translatable\Translatable;
6
use Illuminate\Database\Eloquent\Model as Eloquent;
7
8
class Person extends Eloquent
9
{
10
    protected $table = 'people';
11
12
    use Translatable;
13
14
    /**
15
     * Array with the fields translated in the Translation table.
16
     *
17
     * @var array
18
     */
19
    public $translatedAttributes = ['name'];
20
21
    /**
22
     * Set $translationModel if you want to overwrite the convention
23
     * for the name of the translation Model. Use full namespace if applied.
24
     *
25
     * The convention is to add "Translation" to the name of the class extending Translatable.
26
     * Example: Country => CountryTranslation
27
     */
28
    public $translationModel;
29
30
    /**
31
     * This is the foreign key used to define the translation relationship.
32
     * Set this if you want to overwrite the laravel default for foreign keys.
33
     *
34
     * @var
35
     */
36
    public $translationForeignKey;
37
38
    /**
39
     * Add your translated attributes here if you want
40
     * fill them with mass assignment.
41
     *
42
     * @var array
43
     */
44
    public $fillable = ['name'];
45
46
    /**
47
     * The database field being used to define the locale parameter in the translation model.
48
     * Defaults to 'locale'.
49
     *
50
     * @var string
51
     */
52
    public $localeKey;
53
54
    /**
55
     * Mutate name attribute into upper-case.
56
     *
57
     * @param $value
58
     *
59
     * @return string
60
     */
61
    public function getNameAttribute($value)
62
    {
63
        return ucfirst($value);
64
    }
65
}
66