44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\CMS\Handlers\Search;
|
|
|
|
use App\Models\Content\Content as ContentModel;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class Content extends Search
|
|
{
|
|
/**
|
|
* Search for given patttern/term
|
|
*
|
|
* @param string $term searched word
|
|
*
|
|
* @return array|\Illuminate\Database\Eloquent\Collection|Collection|static[]
|
|
*/
|
|
public function search($term)
|
|
{
|
|
if (Auth::user()
|
|
->cannot('manage', ContentModel::class)) {
|
|
return new Collection();
|
|
}
|
|
|
|
$token = $this->tokenize($term);
|
|
|
|
return ContentModel::where('pageContent', 'LIKE', $token)
|
|
->orWhere('metaDescription', 'LIKE', $token)
|
|
->orWhere('metaKeywords', 'LIKE', $token)
|
|
->orWhere('title', 'LIKE', $token)
|
|
->orWhere('url', 'LIKE', $token)
|
|
->get();
|
|
}
|
|
|
|
public function getId()
|
|
{
|
|
return 'content';
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return trans('search.content');
|
|
}
|
|
} |