public function setEmblemAttribute($value) { $hash = Hash::where('extra', $value)->first(); if ($hash instanceof Hash) { $this->setAttributePullImage('emblem', $hash->hash); } }
public function map($hash, $title = true) { if (strlen($hash) < 1) { $hash = '9999999999'; } if (Hashes::$items == null) { $this->getItems(); } $object = Hashes::$items->filter(function ($item) use($hash) { return $item->hash == $hash; })->first(); if ($object instanceof Hash) { if ($title) { return $object->title; } return $object; } else { if ($this->allowedRetry) { $this->updateHashes(); return $this->map($hash, $title); } else { $classified = Hash::where('hash', '9999999999')->first(); if ($title) { return $classified->title; } return $classified; // throw new HashNotLocatedException($hash); } } }
/** * @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; }
/** * Reverse the migrations. * * @return void */ public function down() { Hash::where('hash', '9999999999')->delete(); }