/** * Execute the console command. * * @return mixed */ public function handle() { //get base food data $this->info('Updating base food data.'); $dataURL = str_replace("{{id}}", "208", $this->baseURL); $data = $this->getCSVFromURL($dataURL); $data = $this->processCSV($data, ['id', 'name', 'calories']); $this->storeCSV('fooddata.csv', $data); //for each of the nutrients we care about, update that data too $nutrients = Nutrient::lists('name', 'id'); foreach ($nutrients as $id => $name) { $this->info('Updating ' . $name . ' data.'); $dataURL = str_replace('{{id}}', $id, $this->baseURL); $data = $this->getCSVFromURL($dataURL); $data = $this->processCSV($data, ['food_id', 'nutrient_id', 'amount_in_food'], ['1' => $id]); $fileName = strtolower(str_replace(' ', '', str_replace('-', '', $name))) . 'data.csv'; $this->storeCSV($fileName, $data); } }