public static function getMarketChangeMessage() { $mostRecentSectorHistoricalsDate = SectorHistoricals::getMostRecentSectorHistoricalsDate(); $marketChange = SectorHistoricals::getMarketChange(); if ($mostRecentSectorHistoricalsDate == date("Y-m-d")) { if ($marketChange < 0) { return "The ASX is down " . $marketChange . "% today."; } elseif ($marketChange >= 0) { return "The ASX is up " . $marketChange . "% today."; } } else { $dayForTitle = date("l", strtotime($mostRecentSectorHistoricalsDate)); if ($marketChange < 0) { return "The ASX was down " . $marketChange . "% on " . $dayForTitle . "."; } elseif ($marketChange >= 0) { return "The ASX was up " . $marketChange . "% on " . $dayForTitle . "."; } } }
public function change() { return view('layouts.partials.market-change-display')->with(['marketChangeMessage' => SectorHistoricals::getMarketChangeMessage(), 'marketChange' => SectorHistoricals::getMarketChange()]); }