/** * get the category data, convert it to an array * check it has data and throw an exception if it does not * @return mixed * @throws DataNotFoundException */ protected function categoryData() { $data = json_decode(json_encode(Afg::categoriesChart($this->selectedYears(), $this->selectedPriorities())), true); if (count($data) < 1) { throw new DataNotFoundException('The options you selected provided no results.'); } return $data; }