mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-29 22:47:42 +00:00 
			
		
		
		
	Fix #4656
This commit is contained in:
		| @@ -22,7 +22,6 @@ declare(strict_types=1); | |||||||
|  |  | ||||||
| namespace FireflyIII\Models; | namespace FireflyIII\Models; | ||||||
|  |  | ||||||
| use Carbon\Carbon; |  | ||||||
| use Eloquent; | use Eloquent; | ||||||
| use FireflyIII\User; | use FireflyIII\User; | ||||||
| use Illuminate\Database\Eloquent\Builder; | use Illuminate\Database\Eloquent\Builder; | ||||||
| @@ -33,13 +32,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
| /** | /** | ||||||
|  * FireflyIII\Models\Preference |  * FireflyIII\Models\Preference | ||||||
|  * |  * | ||||||
|  * @property int $id |  * @property int                             $id | ||||||
|  * @property \Illuminate\Support\Carbon|null $created_at |  * @property \Illuminate\Support\Carbon|null $created_at | ||||||
|  * @property \Illuminate\Support\Carbon|null $updated_at |  * @property \Illuminate\Support\Carbon|null $updated_at | ||||||
|  * @property int $user_id |  * @property int                             $user_id | ||||||
|  * @property string $name |  * @property string                          $name | ||||||
|  * @property int|string|array|null $data |  * @property int|string|array|null           $data | ||||||
|  * @property-read User $user |  * @property-read User                       $user | ||||||
|  * @method static Builder|Preference newModelQuery() |  * @method static Builder|Preference newModelQuery() | ||||||
|  * @method static Builder|Preference newQuery() |  * @method static Builder|Preference newQuery() | ||||||
|  * @method static Builder|Preference query() |  * @method static Builder|Preference query() | ||||||
| @@ -73,19 +72,29 @@ class Preference extends Model | |||||||
|      * |      * | ||||||
|      * @param string $value |      * @param string $value | ||||||
|      * |      * | ||||||
|      * @throws NotFoundHttpException |  | ||||||
|      * @return Preference |      * @return Preference | ||||||
|  |      * @throws NotFoundHttpException | ||||||
|      */ |      */ | ||||||
|     public static function routeBinder(string $value): Preference |     public static function routeBinder(string $value): Preference | ||||||
|     { |     { | ||||||
|         if (auth()->check()) { |         if (auth()->check()) { | ||||||
|             /** @var User $user */ |             /** @var User $user */ | ||||||
|             $user = auth()->user(); |             $user = auth()->user(); | ||||||
|             /** @var Preference $preference */ |             /** @var Preference|null $preference */ | ||||||
|             $preference = $user->preferences()->where('name', $value)->first(); |             $preference = $user->preferences()->where('name', $value)->first(); | ||||||
|             if (null !== $preference) { |             if (null !== $preference) { | ||||||
|                 return $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; |         throw new NotFoundHttpException; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -850,4 +850,11 @@ return [ | |||||||
|     'valid_asset_fields'        => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'], |     '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_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'], |     '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', | ||||||
|  |     ], | ||||||
| ]; | ]; | ||||||
|   | |||||||
| @@ -123,7 +123,7 @@ export default { | |||||||
|     initialiseList: function () { |     initialiseList: function () { | ||||||
|       this.loading = true; |       this.loading = true; | ||||||
|       this.accounts = []; |       this.accounts = []; | ||||||
|       axios.get('./api/v1/preferences/frontpageAccounts') |       axios.get('./api/v1/preferences/frontPageAccounts') | ||||||
|           .then(response => { |           .then(response => { | ||||||
|                   this.loadAccounts(response); |                   this.loadAccounts(response); | ||||||
|                 } |                 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user