unique('portfolio_id')->pluck('portfolio_id'); $portfoliosWithAccess = Portfolio::fullAccess($this->backupImport->user_id) ->whereIn('id', $importingPortfolios) ->count(); if ( $importingPortfolios->count() > $portfoliosWithAccess ) { throw new \Exception(__('You do not have access to that portfolio.')); } } }