mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 12:11:08 -04:00
v6 update
This commit is contained in:
@ -9,6 +9,8 @@ class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['option', 'value'];
|
||||
|
||||
public static function setSetting($key, $setting)
|
||||
{
|
||||
$old = self::whereOption($key)->first();
|
||||
@ -26,6 +28,21 @@ class Setting extends Model
|
||||
$set->save();
|
||||
}
|
||||
|
||||
public static function setSettings($settings)
|
||||
{
|
||||
foreach ($settings as $key => $value) {
|
||||
self::updateOrCreate(
|
||||
[
|
||||
'option' => $key,
|
||||
],
|
||||
[
|
||||
'option' => $key,
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSetting($key)
|
||||
{
|
||||
$setting = static::whereOption($key)->first();
|
||||
@ -36,4 +53,12 @@ class Setting extends Model
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSettings($settings)
|
||||
{
|
||||
return static::whereIn('option', $settings)
|
||||
->get()->mapWithKeys(function ($item) {
|
||||
return [$item['option'] => $item['value']];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user