Completed
Push — master ( 0a8774...ab7e17 )
by Manuel
02:49 queued 11s
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\Models;
4
5
use Illuminate\Support\Carbon;
6
7
/**
8
 * @property int id
9
 * @property string key
10
 * @property string value
11
 * @property Carbon created_at
12
 * @property Carbon updated_at
13
 */
14
class Option extends BaseModel
15
{
16
    public static function getValueByKey(string $key, $default = null): ?string
17
    {
18
        $option = static::query()->where('key', $key)->first();
19
20
        return $option ? $option->value : $default;
21
    }
22
}
23