many updates 😁
This commit is contained in:
@@ -90,7 +90,12 @@ class BaseRepository
|
||||
}
|
||||
|
||||
$values = array_values($data);
|
||||
$values[] = $instance->id ?? $instance->getId();
|
||||
|
||||
if(is_array($instance) && $instance['id']) {
|
||||
$values[] = $instance['id'];
|
||||
} else {
|
||||
$values[] = $instance->id ?? $instance->getId();
|
||||
}
|
||||
|
||||
return $this->db->query(
|
||||
"UPDATE {$this->table} SET {$set} WHERE id=?",
|
||||
|
||||
@@ -21,19 +21,27 @@ class SettingRepository extends BaseRepository implements SettingRepositoryContr
|
||||
*/
|
||||
public function updateSettings(array $data)
|
||||
{
|
||||
$this->destroyAll();
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$isArray = is_array($value) ? 1 : 0;
|
||||
if ($isArray) {
|
||||
$value = implode(',', $value);
|
||||
}
|
||||
$this->create([
|
||||
'setting' => $key,
|
||||
'value' => $value,
|
||||
'is_array' => $isArray,
|
||||
]);
|
||||
$ins = $this->findWhere('setting', $key);
|
||||
if (empty($ins)) {
|
||||
$this->create([
|
||||
'setting' => $key,
|
||||
'value' => $value,
|
||||
'is_array' => $isArray,
|
||||
]);
|
||||
} else {
|
||||
$this->update($ins[0], [
|
||||
'setting' => $key,
|
||||
'value' => $value,
|
||||
'is_array' => $isArray,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user