Book Image

Laravel Application Development Cookbook

By : Terry Matula
Book Image

Laravel Application Development Cookbook

By: Terry Matula

Overview of this book

When creating a web application, there are many PHP frameworks from which to choose. Some are very easy to set up, and some have a much steeper learning curve. Laravel offers both paths. You can do a quick installation and have your app up-and-running in no time, or you can use Laravel's extensibility to create an advanced and fully-featured app.Laravel Application Development Cookbook provides you with working code examples for many of the common problems that web developers face. In the process, it will also allow both new and existing Laravel users to expand their knowledge of the framework.This book will walk you through all aspects of Laravel development. It begins with basic set up and installation procedures, and continues through more advanced use cases. You will also learn about all the helpful features that Laravel provides to make your development quick and easy. For more advanced needs, you will also see how to utilize Laravel's authentication features and how to create a RESTful API.In the Laravel Application Development Cookbook, you will learn everything you need to know about a great PHP framework, with working code that will get you up-and-running in no time.
Table of Contents (18 chapters)
Laravel Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a sortable table using jQuery and Laravel


When handling large amounts of data, it can be helpful to display it in a table view. To manipulate the data, such as for sorting or searching, we can use the data tables JavaScript library. This way, we don't need to keep making database calls every time we want to change the view.

Getting ready

For this recipe, we need a standard installation of Laravel and a properly configured MySQL database.

How to do it...

Follow the given steps to complete this recipe:

  1. In our database, create a new table and add some example data using the following commands:

    DROP TABLE IF EXISTS bookprices;
    CREATE TABLE bookprices (id int(10) unsigned NOT NULL AUTO_INCREMENT,price float(10,2) DEFAULT NULL,book varchar(100) DEFAULT NULL,PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
      INSERT INTO bookprices VALUES ('1', '14.99', 'Alice in Wonderland');
      INSERT INTO bookprices VALUES ('2', '24.50', 'Frankenstein');
      INSERT INTO bookprices VALUES ('3', '29.80', ...