Display spaces in settings
MODIFY
app/Http/Controllers/SettingsController.php
app/Http/Controllers/SettingsController.php
@@ -91,6 +91,12 @@ class SettingsController extends Controller {
return view('settings.account');
}
+ public function getSpaces() {
+ return view('settings.spaces.index', [
+ 'spaces' => Auth::user()->spaces
+ ]);
+ }
+
public function getPreferences() {
return view('settings.preferences', [
'languages' => config('app.locales'),

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

MODIFY
resources/views/settings/layout.blade.php
resources/views/settings/layout.blade.php
<li><a href="/settings/profile"><i class="fas fa-user fa-sm"></i> {{ __('general.profile') }}</a></li>
<li><a href="/settings/account"><i class="fas fa-lock fa-sm"></i> {{ __('general.account') }}</a></li>
<li><a href="/settings/preferences"><i class="fas fa-sliders-h fa-sm"></i> {{ __('general.preferences') }}</a></li>
+ <li><a href="/settings/spaces"><i class="fas fa-rocket fa-sm"></i> {{ __('general.spaces') }}</a></li>
</ul>
</div>
</div>

ADD
resources/views/settings/spaces/index.blade.php
+@extends('settings.layout')
+
+@section('settings_body')
+ <div class="box">
+ <ul class="box__section">
+ @foreach ($spaces as $space)
+ <li>{{ $space->name }} &middot; {{ ucfirst($space->pivot->role) }}</li>
+ @endforeach
+ </ul>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -70,6 +70,7 @@ Route::group(['middleware' => ['auth']], function () {
Route::get('/settings/profile', 'SettingsController@getProfile')->name('profile');
Route::get('/settings/account', 'SettingsController@getAccount')->name('account');
Route::get('/settings/preferences', 'SettingsController@getPreferences')->name('preferences');
+ Route::get('/settings/spaces', 'SettingsController@getSpaces')->name('spaces.index');
});
Route::get('/spaces/{id}', 'SpaceController');

Display spaces in settings