Completed
Push — master ( a76360...3b8ebd )
by Manuel
04:51 queued 03:32
created

Option::getValueByKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Oscer\Cms\Core\Options\Models;
4
5
use Illuminate\Support\Carbon;
6
use Oscer\Cms\Core\Models\BaseModel;
7
8
/**
9
 * @property int id
10
 * @property string key
11
 * @property string value
12
 * @property Carbon created_at
13
 * @property Carbon updated_at
14
 */
15
class Option extends BaseModel
16
{
17
    public static function getValueByKey(string $key, $default = null): ?string
18
    {
19
        $option = static::query()->where('key', $key)->first();
20
21
        return $option ? $option->value : $default;
22
    }
23
}
24