/** * @param array $data Array of Definitions * @param string $index Index for this iteration * @param string $hash Index for hash of item * @param string $title Index for title of item * @param string $desc Index for description of item * @param null $extra Index for anything extra (optional) * @param null $secondary Index for anything secondary extra (optional) * @param null $third Index for a third extra field (optional) * @return bool */ private static function loadDefinitions(&$data, $index, $hash, $title, $desc, $extra = null, $secondary = null, $third = null) { if (isset($data[$index])) { foreach ($data[$index] as $item) { if (($mHash = Hash::where('hash', $item[$hash])->first()) == null) { $mHash = new Hash(); } // There are some records in the Hash response that have "FIELD_HIDDEN" // Probably from a future DLC, but we can't decode these. So skip em. if (!isset($item[$title])) { continue; } $mHash->hash = $item[$hash]; $mHash->title = $item[$title]; $mHash->description = isset($item[$desc]) ? $item[$desc] : null; $mHash->extra = $extra != null ? $item[$extra] : null; if ($secondary != null) { $mHash->extraSecondary = isset($item[$secondary]) ? $item[$secondary] : null; } if ($third != null) { $mHash->extraThird = isset($item[$third]) ? $item[$third] : null; } $mHash->save(); } } return false; }