Author: XE Developers (developers@xpressengine.com)
Ejemplo n.º 1
0
 public function testExecute()
 {
     $instance = new Decomposer();
     $this->assertEquals('ㄱㅏㄴㅏㄷㅏ', $instance->execute('가나다'));
     $this->assertEquals('ㄱㅏabㄴㅏcㄷㅏde', $instance->execute('가ab나c다de'));
     $this->assertEquals('aㄱㅏㄴㅏ bcㄷㅏ de', $instance->execute('a가나 bc다 de'));
 }
Ejemplo n.º 2
0
 /**
  * Search similar tags by given string
  *
  * @param string      $string     partial of word
  * @param int         $take       take count
  * @param string|null $instanceId instance id of taggable
  * @return Collection|static[]
  */
 public function similar($string, $take = 15, $instanceId = null)
 {
     $model = $this->createModel();
     $query = $model->newQuery()->where('decomposed', 'like', $this->decomposer->execute($string) . '%')->orderBy('count', 'desc')->take($take);
     if ($instanceId) {
         $query->where('instanceId', $instanceId);
     }
     return $query->get();
 }