Esempio n. 1
0
 /**
  * @return Keywords
  */
 public function keywords()
 {
     if (null == $this->keywords) {
         $this->keywords = Keywords::query()->where('keywordable_type = :type:', ['type' => get_class($this)])->andWhere('keywordable_id = :id:', ['id' => $this->id])->execute()->getFirst();
     }
     return $this->keywords;
 }
Esempio n. 2
0
 private function searchByType($text, $Excluded = [], $type = 'Movies')
 {
     $query = Keywords::query()->where('MATCH(keywords) AGAINST("' . $this->keywords_encode($text) . '")')->andWhere('Keywords.keywordable_type = "' . $type . '"')->leftJoin($type, $type . '.id = Keywords.keywordable_id AND Keywords.keywordable_type = "' . $type . '"')->columns([$type . '.*', 'Keywords.*'])->limit(10);
     if ($Excluded != []) {
         $query = $query->notInWhere($type . '.id', $Excluded);
     }
     $rows = $query->execute();
     $result = [];
     foreach ($rows as $row) {
         $result[] = $row->{strtolower($type)};
     }
     return $result;
 }