Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #4656
James Cole99f08da4df79
diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex f473853d77..defa83e588 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -22,7 +22,6 @@ declare(strict_types=1);namespace FireflyIII\Models;-use Carbon\Carbon;use Eloquent;use FireflyIII\User;use Illuminate\Database\Eloquent\Builder;@@ -33,13 +32,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Preference*- * @property int $id+ * @property int $id* @property \Illuminate\Support\Carbon|null $created_at* @property \Illuminate\Support\Carbon|null $updated_at- * @property int $user_id- * @property string $name- * @property int|string|array|null $data- * @property-read User $user+ * @property int $user_id+ * @property string $name+ * @property int|string|array|null $data+ * @property-read User $user* @method static Builder|Preference newModelQuery()* @method static Builder|Preference newQuery()* @method static Builder|Preference query()@@ -73,19 +72,29 @@ class Preference extends Model** @param string $value*- * @throws NotFoundHttpException* @return Preference+ * @throws NotFoundHttpException*/public static function routeBinder(string $value): Preference{if (auth()->check()) {/** @var User $user */$user = auth()->user();- /** @var Preference $preference */+ /** @var Preference|null $preference */$preference = $user->preferences()->where('name', $value)->first();if (null !== $preference) {return $preference;}+ $default = config('firefly.default_preferences');+ if (array_key_exists($value, $default)) {+ $preference = new Preference;+ $preference->name = $value;+ $preference->data = $default[$value];+ $preference->user_id = $user->id;+ $preference->save();++ return $preference;+ }}throw new NotFoundHttpException;}diff --git a/config/firefly.php b/config/firefly.phpindex f976855765..839547424f 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -850,4 +850,11 @@ return ['valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],+ 'default_preferences' => [+ 'frontPageAccounts' => [],+ 'listPageSize' => 50,+ 'currencyPreference' => 'EUR',+ 'language' => 'en_US',+ 'locale' => 'equal',+ ],];diff --git a/frontend/src/components/dashboard/MainAccountList.vue b/frontend/src/components/dashboard/MainAccountList.vueindex 9155c9453c..e27ee66964 100644--- a/frontend/src/components/dashboard/MainAccountList.vue+++ b/frontend/src/components/dashboard/MainAccountList.vue@@ -123,7 +123,7 @@ export default {initialiseList: function () {this.loading = true;this.accounts = [];- axios.get('./api/v1/preferences/frontpageAccounts')+ axios.get('./api/v1/preferences/frontPageAccounts').then(response => {this.loadAccounts(response);}