示例#1
0
 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 \Illuminate\Database\Eloquent\Collection|static[] $collection
  */
 public function generateArrayData($collection)
 {
     $modelObject = $collection->first();
     $arrayData = array();
     foreach ($collection as $item) {
         $row = array();
         foreach ($modelObject->getListAttributes() as $index => $value) {
             $row[] = $item->{$index};
         }
         $pk = $modelObject->getPrimaryKey();
         $href = route('admin_edit', ['model' => $this->model->getUrlName(), 'id' => "{$pk}:{$item->{$pk}}"]);
         $row[] = "<a href='{$href}'>Editar</a>";
         $arrayData[] = $row;
     }
     return $arrayData;
 }
 /**
  * Get a setting by its handle.
  *
  * @param string $handle
  *
  * @return Setting
  */
 public function get($handle)
 {
     $this->setting = $this->items->where('handle', $handle)->first();
     return $this->setting;
 }