FEATURE: register file searching
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace App\Handlers\Search;
|
||||
|
||||
use App\Models\File;
|
||||
|
||||
class Files extends Search
|
||||
{
|
||||
public function getId()
|
||||
{
|
||||
return "files";
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return trans('search.files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for given patttern/term
|
||||
*
|
||||
* @param string $term searched word
|
||||
*
|
||||
* @return array list of found objects
|
||||
*/
|
||||
public function search($term)
|
||||
{
|
||||
$token = $this->tokenize($term);
|
||||
|
||||
return File::where('original_filename', 'LIKE', $token)
|
||||
->orWhere('keywords', 'LIKE', $token)
|
||||
->orWhere('description', 'LIKE', $token)
|
||||
->orWhere('mime_type', 'LIKE', $token)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace App\Handlers\Search\Presenters;
|
||||
|
||||
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||
|
||||
class AdminFiles implements SearchPresenterHandler
|
||||
{
|
||||
/**
|
||||
* Method for rendering list of found results
|
||||
*
|
||||
* @param $foundItems
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($foundItems)
|
||||
{
|
||||
return view('admin.fileManager.filesTiles', ['files' => $foundItems]);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@ use App\Handlers\Registrators\SettingsExtensionRegistrator;
|
||||
use App\Handlers\Registrators\TemplateRegistrator;
|
||||
use App\Handlers\Registrators\WidgetRegistrator;
|
||||
use App\Handlers\Search\Content;
|
||||
use App\Handlers\Search\Files;
|
||||
use App\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
||||
use App\Handlers\Search\Presenters\AdminFiles;
|
||||
use App\Widgets\HtmlCode\HtmlCode;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -108,5 +110,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
$registrator = $this->app->make('registerSearchEngine');
|
||||
|
||||
$registrator->register(new Content(), new AdminContentPresenter());
|
||||
$registrator->register(new Files(), new AdminFiles());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'content' => 'Content',
|
||||
'term' => 'Search',
|
||||
'results' => 'Found results',
|
||||
'pageTitle' => 'Search'
|
||||
'content' => 'Content',
|
||||
'term' => 'Search',
|
||||
'results' => 'Found results',
|
||||
'pageTitle' => 'Search',
|
||||
'files' => 'Files',
|
||||
'emptyString' => 'Cannot search for empty string!'
|
||||
];
|
||||
Reference in New Issue
Block a user