Check if space is accessible by user while attempting to switch to it
MODIFY
routes/web.php
routes/web.php
@@ -55,10 +55,12 @@ Route::group(['middleware' => ['auth']], function () {
Route::post('/settings', 'SettingsController@store');
Route::get('/spaces/{id}', function ($id) {
- // TODO CHECK IF SPACE IS ACCESSIBLE BY USER
-
$space = App\Space::find($id);
+ if ($space->users->contains(Auth::user()->id)) {
+ return redirect()->route('dashboard');
+ }
+
session(['space' => $space]);
return redirect()->route('dashboard');

Check if space is accessible by user while attempting to switch to it