Skip to content

Instantly share code, notes, and snippets.

@elliotforbes
Created November 4, 2015 20:53
Show Gist options
  • Save elliotforbes/62b8a010b9da16756de5 to your computer and use it in GitHub Desktop.
Save elliotforbes/62b8a010b9da16756de5 to your computer and use it in GitHub Desktop.
public function search(Request $request)
{
// Gets the query string from our form submission
$query = Request::input('search');
// 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.
$articles = DB::table('articles')->where('title', 'LIKE', '%' . $query . '%')->paginate(10);
// returns a view and passes the view the list of articles and the original query.
return view('page.search', compact('articles', 'query'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment