When displaying data to a user, it could be convenient to allow them to filter the data. So we don't have to make the user click on submit and reload the page every time, we can do all the filtering using Ajax. For this recipe, we'll make a book list and allow the user to filter it based on the genre.
For this recipe, we need a standard Laravel installation that's configured to work with a database. We'll need to set up a table to use by running this SQL statement:
DROP TABLE IF EXISTS books; CREATE TABLE books (id int(10) unsigned NOT NULL AUTO_INCREMENT,name varchar(255) DEFAULT NULL,author varchar(255) DEFAULT NULL,genre varchar(255) DEFAULT NULL,PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO books VALUES ('1', 'Alice in Wonderland', 'Lewis Carroll', 'fantasy'); INSERT INTO books VALUES ('2', 'Tom Sawyer', 'Mark Twain', 'comedy'); INSERT INTO books VALUES ('3', 'Gulliver\'s Travels', 'Jonathan Swift', ...