public static function getSectorPercentChange($sectorName, $stocksInSector) { $yesterdaysSectorHistoricalsDate = SectorHistoricals::getYesterdaysSectorHistoricalsDate(); $yesterdaysTotalMarketCap = SectorHistoricals::where(['date' => $yesterdaysSectorHistoricalsDate, 'sector' => $sectorName])->pluck('total_sector_market_cap'); if ($yesterdaysTotalMarketCap > 0) { return 100 / $yesterdaysTotalMarketCap * SectorHistoricals::getSectorTotalChange($stocksInSector); } return 0; }