mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-21 05:53:08 -06:00
Fix for #2049
This commit is contained in:
parent
1fc2c998de
commit
25b2b43a38
@ -216,8 +216,22 @@ class Preferences
|
|||||||
{
|
{
|
||||||
$fullName = sprintf('preference%s%s', $user->id, $name);
|
$fullName = sprintf('preference%s%s', $user->id, $name);
|
||||||
Cache::forget($fullName);
|
Cache::forget($fullName);
|
||||||
|
/** @var Preference $pref */
|
||||||
$pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);
|
$pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);
|
||||||
|
|
||||||
|
if (null !== $pref && null === $value) {
|
||||||
|
try {
|
||||||
|
$pref->delete();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error(sprintf('Could not delete preference: %s', $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Preference;
|
||||||
|
}
|
||||||
|
if (null === $value) {
|
||||||
|
return new Preference;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $pref) {
|
if (null !== $pref) {
|
||||||
$pref->data = $value;
|
$pref->data = $value;
|
||||||
$pref->save();
|
$pref->save();
|
||||||
|
Loading…
Reference in New Issue
Block a user