diff --git a/src/Searchable.php b/src/Searchable.php index 499783a..8a0b69b 100644 --- a/src/Searchable.php +++ b/src/Searchable.php @@ -160,25 +160,22 @@ public function shouldSyncDocument() } /** - * Handle dynamic method calls into the model. - * - * @param string $method - * @param array $parameters + * Start an elastic dsl search query builder. * * @return mixed */ - public function __call($method, $parameters) + public static function search() { - if ($method == 'search') { - //Start an elastic dsl search query builder - return Plastic::search()->model($this); - } - - if ($method == 'suggest') { - //Start an elastic dsl suggest query builder - return Plastic::suggest()->index($this->getDocumentIndex()); - } + return Plastic::search()->model(new static()); + } - return parent::__call($method, $parameters); + /** + * Start an elastic dsl suggest query builder. + * + * @return mixed + */ + public static function suggest() + { + return Plastic::suggest()->index((new static())->getDocumentIndex()); } }