Test Failed
Pull Request — master (#85)
by Keoghan
06:33
created

Setting   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 13
ccs 0
cts 5
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateOrCreate() 0 9 2
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Setting extends Model
8
{
9
    protected $guarded = [];
10
11
    public static function updateOrCreate($name, $value)
12
    {
13
        $setting = static::where('name', $name)->first();
14
15
        if ($setting) {
16
            return  $setting->update(['value' => $value]);
17
        }
18
19
        return static::create(['name' => $name, 'value' => $value]);
20
    }
21
}
22