Ejemplo n.º 1
0
 /**
  * @param array $models
  * @return void
  */
 public function addEagerConstraints(array $models)
 {
     $this->buildDictionary($this->models = Collection::make($models));
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 public function isCurrentRoute()
 {
     if (strpos($this->attributes['link'], 'http://') === false && strpos($this->attributes['link'], 'https://') === false) {
         if (strpos($this->attributes['link'], 'category') !== false) {
             $tmp = trim($this->attributes['link'], '/');
             $tmp = explode('/', $tmp);
             if (is_numeric($tmp[1])) {
                 $id = $tmp[1];
                 $collection = Collection::make();
                 $ids = [];
                 if (Container::getInstance()->make('request')->route("article")) {
                     $article = Article::find(Container::getInstance()->make('request')->route("article"));
                     if ($article instanceof Article) {
                         Category::getAllParentCategories($article->category->id, $collection);
                     }
                     foreach ($collection as $category) {
                         $ids[] = $category->id;
                     }
                     $ids = array_unique($ids);
                     if (in_array($id, $ids)) {
                         return true;
                     }
                 } else {
                     Category::getAllSubCategories($id, $collection);
                     $ids[] = $id;
                     foreach ($collection as $category) {
                         $ids[] = $category->id;
                     }
                     $ids = array_unique($ids);
                     $current = Container::getInstance()->make('request')->route("category");
                     if (in_array($current, $ids)) {
                         return true;
                     }
                 }
             }
         } else {
             return Container::getInstance()->make('request')->is($this->attributes['link'] . '*') ? true : false;
         }
     }
 }