Feat: Adds multi currency support (#88)
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Laravel\Jetstream\HasProfilePhoto;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
@@ -31,6 +32,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'options',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -50,6 +52,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'admin' => 'boolean',
|
||||
'options' => 'json',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -82,4 +86,16 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
ELSE COALESCE(market_data.market_value - transactions.cost_basis, 0)
|
||||
END AS gain_dollars');
|
||||
}
|
||||
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return Arr::get($this->options, 'display_currency') ?? config('investbrain.base_currency');
|
||||
}
|
||||
|
||||
public function getLocale(): string
|
||||
{
|
||||
$available_locales = Arr::pluck(config('app.available_locales'), 'locale');
|
||||
|
||||
return Arr::get($this->options, 'locale') ?? request()->getPreferredLanguage($available_locales) ?? config('app.locale');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user