Completed
Push — dev ( 40c7a5...93901c )
by Zach
03:40
created

TextBlock::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Larafolio\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class TextBlock extends Model
9
{
10
    use SoftDeletes;
11
12
    /**
13
     * The table associated with the model.
14
     *
15
     * @var string
16
     */
17
    protected $table = 'text_blocks';
18
19
    /**
20
     * The attributes that should be mutated to dates.
21
     *
22
     * @var array
23
     */
24
    protected $dates = ['deleted_at'];
25
26
    /**
27
     * The attributes that are mass assignable.
28
     *
29
     * @var array
30
     */
31
    protected $fillable = ['name', 'text', 'formatted_text', 'order'];
32
33
    /**
34
     * Convert camelCase properties to snake_case properties and try again.
35
     *
36
     * @param  string $key
37
     *
38
     * @return mixed
39
     */
40
    public function __get($key)
41
    {
42
        $attribute = parent::__get($key);
43
44
        if ($attribute === null) {
45
            $snakeCase = snake_case($key);
46
47
            $attribute = parent::__get($snakeCase);
48
        }
49
50
        return $attribute;
51
    }
52
}
53