Total Complexity | 6 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class SettingRepo |
||
6 | { |
||
7 | public static function getSetting($name) |
||
11 | }); |
||
12 | } |
||
13 | |||
14 | public static function resetSettings($data) |
||
15 | { |
||
16 | foreach ($data as $row) { |
||
17 | $count = self::table()->where('name', $row['name'])->count(); |
||
18 | if (! $count) { |
||
19 | self::table()->insert($row); |
||
20 | continue; |
||
21 | } |
||
22 | if ($count > 1) { |
||
23 | $rowId = self::table()->where('name', $row['name'])->orderby('id', 'asc')->first()->id; |
||
24 | self::table()->where('name', $row['name'])->where('id', '!=', $rowId)->delete(); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return mixed |
||
31 | */ |
||
32 | private static function table() |
||
35 | } |
||
36 | } |