firefly-iii/app/controllers/SearchController.php

42 lines
1.4 KiB
PHP
Raw Normal View History

<?php
use FireflyIII\Exception\NotImplementedException;
2014-09-22 00:25:14 -05:00
2014-08-10 08:01:46 -05:00
/**
* Class SearchController
*/
class SearchController extends BaseController
{
2014-08-10 08:01:46 -05:00
/**
2014-09-22 00:25:14 -05:00
* Results always come in the form of an array [results, count, fullCount]
2014-08-10 08:01:46 -05:00
*/
public function index()
{
throw new NotImplementedException;
2014-09-22 00:25:14 -05:00
$subTitle = null;
2014-09-26 23:06:31 -05:00
$rawQuery = null;
$result = [];
2014-09-22 00:25:14 -05:00
if (!is_null(Input::get('q'))) {
$rawQuery = trim(Input::get('q'));
$words = explode(' ', $rawQuery);
$subTitle = 'Results for "' . e($rawQuery) . '"';
2014-09-26 23:06:31 -05:00
$transactions = $this->_helper->searchTransactions($words);
$accounts = $this->_helper->searchAccounts($words);
$categories = $this->_helper->searchCategories($words);
$budgets = $this->_helper->searchBudgets($words);
$tags = $this->_helper->searchTags($words);
$result = [
'transactions' => $transactions,
'accounts' => $accounts,
'categories' => $categories,
'budgets' => $budgets,
'tags' => $tags
];
2014-09-22 00:25:14 -05:00
}
return View::make('search.index')->with('title', 'Search')->with('subTitle', $subTitle)->with(
'mainTitleIcon', 'fa-search'
2014-09-26 23:06:31 -05:00
)->with('query', $rawQuery)->with('result',$result);
}
}