mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #4656
This commit is contained in:
parent
2f9724e7ca
commit
99f08da4df
@ -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;
|
||||
}
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user