Skip to content

Firefly III: a personal finances manager

Preference list

Sander Dorigo74341be2f2d6
diff --git a/app/Api/V1/Controllers/User/PreferencesController.php b/app/Api/V1/Controllers/User/PreferencesController.php
index f42ce7686e..4137bd4c4c 100644
--- a/app/Api/V1/Controllers/User/PreferencesController.php
+++ b/app/Api/V1/Controllers/User/PreferencesController.php
@@ -104,6 +104,7 @@ final class PreferencesController extends Controller
$manager = $this->getManager();
$count = $preferenceList->count();
$names = implode(',', $preferenceList->pluck('name')->toArray());
+ var_dump($names);exit;
// make paginator:
$paginator = new LengthAwarePaginator($preferenceList, $count, 31_337, 1);
@@ -114,6 +115,7 @@ final class PreferencesController extends Controller
$resource = new FractalCollection($preferenceList, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
+ die('here we are2');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Support/Binder/PreferenceList.php b/app/Support/Binder/PreferenceList.php
index 6c0d638fa9..08f0357ae8 100644
--- a/app/Support/Binder/PreferenceList.php
+++ b/app/Support/Binder/PreferenceList.php
@@ -51,6 +51,9 @@ class PreferenceList implements BinderInterface
$result = new Collection();
foreach ($list as $item) {
$current = Preferences::get($item);
+ if (null === $current) {
+ $current = Preferences::set($item, null, false);
+ }
if (null !== $current) {
Log::debug(sprintf('Add %s to the result', $item));
$result->push($current);
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index a771bfcb85..2183d484a4 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -123,6 +123,7 @@ class Preferences
if (null === $user) {
$preference = new Preference();
$preference->data = $default;
+ $preference->name = $name;
return $preference;
}