This commit is contained in:
Julian Prieber 2023-02-16 16:10:41 +01:00
parent 231586b69a
commit 40dd951c01

View File

@ -14,10 +14,10 @@ class UserData extends Model
$userData = self::where('id', $userId)->first(); $userData = self::where('id', $userId)->first();
if (!$userData) { if (!$userData) {
return; return "null";
} }
$data = json_decode($userData->image, true); $data = json_decode($userData->image, true) ?? [];
$data[$key] = $value; $data[$key] = $value;
$userData->image = json_encode($data); $userData->image = json_encode($data);
@ -29,10 +29,10 @@ class UserData extends Model
$userData = self::where('id', $userId)->first(); $userData = self::where('id', $userId)->first();
if (!$userData || !$userData->image) { if (!$userData || !$userData->image) {
return null; return "null";
} }
$data = json_decode($userData->image, true); $data = json_decode($userData->image, true) ?? [];
return isset($data[$key]) ? $data[$key] : null; return isset($data[$key]) ? $data[$key] : null;
} }
@ -42,10 +42,10 @@ class UserData extends Model
$userData = self::where('id', $userId)->first(); $userData = self::where('id', $userId)->first();
if (!$userData || !$userData->image) { if (!$userData || !$userData->image) {
return; return "null";
} }
$data = json_decode($userData->image, true); $data = json_decode($userData->image, true) ?? [];
if (isset($data[$key])) { if (isset($data[$key])) {
unset($data[$key]); unset($data[$key]);