Created
November 4, 2015 20:53
-
-
Save elliotforbes/62b8a010b9da16756de5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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