move search logic to frontend
This commit is contained in:
parent
783ac823ba
commit
98f50a2b6f
18 changed files with 330 additions and 76 deletions
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use App\Exceptions\GeneralException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Page;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
@ -45,9 +43,10 @@ class HomeController extends Controller
|
|||
|
||||
// }
|
||||
return view('frontend.home.index');
|
||||
// return view('welcome');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
|
@ -96,7 +95,7 @@ class HomeController extends Controller
|
|||
if (!is_null(Page::query()->wherePage_slug($slug)->firstOrFail())) {
|
||||
$result = Page::query()->wherePage_slug($slug)->firstOrFail();
|
||||
return view('frontend.pages.index')
|
||||
->withpage($result);
|
||||
->withpage($result);
|
||||
} else {
|
||||
throw new GeneralException(trans('exceptions.backend.access.pages.not_found'));
|
||||
}
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Book;
|
||||
use App\Dataset;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Library\Search\Navigation;
|
||||
use App\Library\Util\SolrSearchSearcher;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
private $_query;
|
||||
private $_numOfHits;
|
||||
private $_searchtype;
|
||||
private $_resultList;
|
||||
private $_facetMenu;
|
||||
private $query;
|
||||
private $numOfHits;
|
||||
private $searchtype;
|
||||
private $resultList;
|
||||
private $facetMenu;
|
||||
|
||||
protected $client;
|
||||
|
||||
|
@ -53,16 +54,16 @@ class SearchController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function search1(Request $request) : View
|
||||
public function search1(Request $request): View
|
||||
{
|
||||
$this->_request = $request;
|
||||
$data=$request->all();
|
||||
//$this->_searchtype = $request->input('searchtype');
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
return view('rdr.solrsearch.index');
|
||||
$data = $request->all();
|
||||
//$this->searchtype = $request->input('searchtype');
|
||||
$this->searchtype = $request->input('searchtype');
|
||||
return view('frontend.solrsearch.index');
|
||||
}
|
||||
|
||||
public function search(Request $request) : View
|
||||
public function search(Request $request): View
|
||||
{
|
||||
Log::info('Received new search request. Redirecting to search action of IndexController.');
|
||||
$this->_request = $request;
|
||||
|
@ -76,10 +77,10 @@ class SearchController extends Controller
|
|||
// // // display the total number of documents found by solr
|
||||
// echo 'NumFound: ' .$results->getNumFound();
|
||||
|
||||
//$this->_query = Navigation::getQueryUrl($request);
|
||||
//$this->query = Navigation::getQueryUrl($request);
|
||||
$query = $this->buildQuery();
|
||||
if (!is_null($query)) {
|
||||
$this->_query = $query;
|
||||
$this->query = $query;
|
||||
$this->performSearch();
|
||||
|
||||
// set start and rows param (comparable to SQL limit) using fluent interface
|
||||
|
@ -87,33 +88,29 @@ class SearchController extends Controller
|
|||
// set fields to fetch (this overrides the default setting 'all fields')
|
||||
//$query->setFields(array('id','year'));
|
||||
|
||||
$results = $this->resultList->getResults();
|
||||
$numOfHits = $this->numOfHits;
|
||||
|
||||
$results = $this->_resultList->getResults();
|
||||
$numOfHits = $this->_numOfHits;
|
||||
|
||||
|
||||
return view('rdr.solrsearch.index', compact('results', 'numOfHits'));
|
||||
return view('frontend.solrsearch.index', compact('results', 'numOfHits'));
|
||||
}
|
||||
return view('rdr.solrsearch.index');
|
||||
return view('frontend.solrsearch.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays simple search form.
|
||||
*/
|
||||
public function index() : View
|
||||
public function index(): View
|
||||
{
|
||||
$totalNumOfDocs = Dataset::count();
|
||||
return view('rdr.solrsearch.index', compact('totalNumOfDocs'));
|
||||
return view('frontend.solrsearch.index', compact('totalNumOfDocs'));
|
||||
}
|
||||
|
||||
|
||||
public function searchDb(Request $request) : View
|
||||
public function searchDb(Request $request): View
|
||||
{
|
||||
$searchType = "simple";
|
||||
$params = $request->all();
|
||||
//build query
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
|
||||
$this->searchtype = $request->input('searchtype');
|
||||
|
||||
// Gets the query string from our form submission
|
||||
//$query = Request::input('search');
|
||||
|
@ -123,19 +120,18 @@ class SearchController extends Controller
|
|||
// Returns an array of articles that have the query string located somewhere within
|
||||
// our articles titles. Paginates them so we can break up lots of search results.
|
||||
$books = Book::where('title', 'LIKE', '%' . $filter . '%')
|
||||
->get();//paginate(10);
|
||||
->get(); //paginate(10);
|
||||
|
||||
// returns a view and passes the view the list of articles and the original query.
|
||||
return view('rdr.solrsearch.index', compact('books'));
|
||||
return view('frontend.solrsearch.index', compact('books'));
|
||||
}
|
||||
|
||||
|
||||
#region private helper
|
||||
|
||||
private function buildQuery()
|
||||
{
|
||||
$request = $this->_request;
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
$this->searchtype = $request->input('searchtype');
|
||||
return Navigation::getQueryUrl($request);
|
||||
}
|
||||
|
||||
|
@ -147,16 +143,16 @@ class SearchController extends Controller
|
|||
//$this->getLogger()->debug('performing search');
|
||||
try {
|
||||
$searcher = new SolrSearchSearcher();
|
||||
// $openFacets = $this->_facetMenu->buildFacetArray( $this->getRequest()->getParams() );
|
||||
// $openFacets = $this->facetMenu->buildFacetArray( $this->getRequest()->getParams() );
|
||||
// $searcher->setFacetArray($openFacets);
|
||||
$this->_resultList = $searcher->search($this->_query);
|
||||
$this->resultList = $searcher->search($this->query);
|
||||
// $this->view->openFacets = $openFacets;
|
||||
} catch (Exception $e) {
|
||||
// $this->getLogger()->err(__METHOD__ . ' : ' . $e);
|
||||
//throw new Application_SearchException($e);
|
||||
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
|
||||
}
|
||||
$this->_numOfHits = $this->_resultList->getNumberOfHits();
|
||||
$this->numOfHits = $this->resultList->getNumberOfHits();
|
||||
}
|
||||
#endregion private helper
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue