FEATURE: add registering for new search engines.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App\Handlers\Search;
|
||||
|
||||
use App\Handlers\Contracts\SearchHandler;
|
||||
|
||||
class Content implements SearchHandler
|
||||
{
|
||||
/**
|
||||
* Search for given patttern/term
|
||||
*
|
||||
* @param string $term searched word
|
||||
*
|
||||
* @return array list of found objects
|
||||
*/
|
||||
public function search($term)
|
||||
{
|
||||
$token = '%' . $term . '%';
|
||||
|
||||
return Content::where('content', 'LIKE', $token)
|
||||
->orWhere('description', 'LIKE', $token)
|
||||
->orWhere('keywords', 'LIKE', $token)
|
||||
->orWhere('title', 'LIKE', $token)
|
||||
->orWhere('url', 'LIKE', $token)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return 'content';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return trans('...');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace App\Handlers\Search\Presenters;
|
||||
|
||||
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||
|
||||
class Content implements SearchPresenterHandler
|
||||
{
|
||||
public function render($foundItems)
|
||||
{
|
||||
var_dump($foundItems);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user