v6 update

This commit is contained in:
Mohit Panjwani
2022-01-10 16:06:17 +05:30
parent b770e6277f
commit bdea879273
722 changed files with 19047 additions and 9186 deletions

View File

@ -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']];
});
}
}