Configuration::key()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Yajra\CMS\Entities;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Configuration
9
 *
10
 * @property string key
11
 * @property string value
12
 */
13
class Configuration extends Model
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $table = 'configurations';
19
20
    /**
21
     * @var array
22
     */
23
    protected $fillable = ['key', 'value'];
24
25
    /**
26
     * Get value by key.
27
     *
28
     * @param string $key
29
     * @return string
30
     */
31
    public static function key($key)
32
    {
33
        $config = static::where('key', $key)->first();
34
35
        return $config->value ?? config($key, null);
36
    }
37
}
38