Skip to content
Snippets Groups Projects
Unverified Commit 01e958ac authored by Robb Lewis's avatar Robb Lewis
Browse files

Date query for search

parent 10146e1b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -56,6 +56,35 @@ class TweetController {
));
}
 
public function searchResults($search, $year = null, $month = null, $date = null)
{
$monthCounts = null;
$dayCounts = null;
$query = new TweetQuery();
$query->search($search);
if ($year) $query->forYear($year);
if ($month) $query->forMonth($month);
if ($date) $query->forDate($date);
list($ids, $tweets) = $this->tweets->all($query);
if (! $month) $monthCounts = $this->tweets->monthCount($ids);
if ($month && ! $date) $dayCounts = $this->tweets->dayCount($ids);
$this->breadcrumbs->addCrumb(count($ids) . ' found containing "' . $search . '"', "search/$search");
if ($year) $this->breadcrumbs->addCrumb($year, $year);
if ($month) $this->breadcrumbs->addCrumb(displayMonth($month), $month);
if ($date) $this->breadcrumbs->addCrumb(displayDate($date), $date);
return view('tweets.index', compact(
'tweets',
'search',
'monthCounts',
'dayCounts'
));
}
public function show($tweetId)
{
$this->breadcrumbs->addCrumb('Tweet ID: ' . $tweetId, $tweetId);
Loading
Loading
@@ -83,16 +112,4 @@ class TweetController {
return redirect('search/'.$search);
}
 
public function searchResults($search)
{
$tweets = $this->tweets->search($search);
$this->breadcrumbs->addCrumb($tweets->total() . ' found containing "' . $search . '"', 'search');
return view('tweets.index', compact(
'tweets',
'search'
));
}
}
\ No newline at end of file
Loading
Loading
@@ -9,6 +9,10 @@ class TweetRepository {
 
protected static $paginate = 50;
 
/**
* @param TweetQuery|null $query
* @return array
*/
public function all(TweetQuery $query = null)
{
if (!$query) $query = new TweetQuery();
Loading
Loading
@@ -109,19 +113,6 @@ class TweetRepository {
}
}
 
/**
* Search tweets
*
* @param String $search
* @return array
*/
public function search($search)
{
return Tweet::where('text', 'LIKE', '%'.$search.'%')
->orderBy('time', 'desc')
->paginate(self::$paginate);
}
public function stats()
{
$clients = $this->topClients();
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment