Move currency relation to Space model
MODIFY
app/Providers/AppServiceProvider.php
app/Providers/AppServiceProvider.php
@@ -11,7 +11,7 @@ class AppServiceProvider extends ServiceProvider {
view()->composer('*', function($view) {
$view->with([
'userName' => Auth::check() ? Auth::user()->name : null,
- 'currency' => Auth::check() ? Auth::user()->currency->symbol : null
+ 'currency' => Auth::check() ? session('space')->currency->symbol : null
]);
});
}

MODIFY
app/Space.php
app/Space.php
@@ -16,6 +16,10 @@ class Space extends Model {
return $this->belongsToMany(User::class, 'user_space');
}
+ public function currency() {
+ return $this->belongsTo(Currency::class);
+ }
+
public function tags() {
return $this->hasMany(Tag::class);
}

MODIFY
app/User.php
app/User.php
@@ -25,8 +25,4 @@ class User extends Authenticatable {
public function spaces() {
return $this->belongsToMany(Space::class, 'user_space')->withPivot('role');
}
-
- public function currency() {
- return $this->belongsTo(Currency::class);
- }
}

Move currency relation to Space model