middleware('auth'); } public function index() { $workspaces = Workspace::forUser(Auth::id()) ->with(['members']) ->withCount(['members']) ->limit(20) ->get() ->map(function (Workspace $workspace) { $workspace->setCurrentUserAndOwner(); return $workspace; }); return $this->success([ 'workspaces' => $workspaces, ]); } }