The book is broken into 12 chapters, each of which is briefly described below.
In this opening chapter you'll learn how to create and configure your Laravel project using your existing PHP development environment, a virtual machine known as Laravel Homestead, and a minimal development environment known as Valet (OSX users only). I'll also show you how to configure your environment in order to effectively debug your Laravel applications, and how to extend Laravel's capabilities by installing several popular third-party packages. We'll conclude the chapter with an introduction to PHPUnit, showing you how to create and execute your first automated Laravel test!
In this chapter we'll turn our attention to the project's data. You'll learn how to integrate and configure the database, manage your database schema using migrations, and easily populate your database using seeds. From there we'll move on to creating models, and how to query the database through these models using the Eloquent object relational mapper. I'll also introduce the concept of resourceful controllers, and we'll generate a controller which will be used to view and manage the example project's events. You'll also learn how how to use Laravel's Query Builder to query the database when Eloquent isn't possible or practical.
Laravel models are incredibly powerful tools, and can be customized in a variety of ways to meet your project's specific needs. In this chapter you'll learn how to override model defaults to create custom accessors and mutators, add instance methods, and use scopes to easily filter database results with minimal code redundancy. You'll also learn how to create sluggable URLs using the eloquent-sluggable package. The chapter concludes with an introduction to testing your models using Laravel's amazing database-specific test features.
The last two chapters were primarily focused upon the many different ways you can query the database. In this chapter we'll turn our attention to creating, updating, and deleting data. In addition to a review of the Eloquent syntax used to perform these tasks, we'll continue building out the resourceful controller created in chapter 3. You'll also learn how to incorporate flash notifications into your controllers and views to keep users updated regarding request outcomes, and how to use Laravel Dusk to test your forms.
For reasons of simplicity, the last chapter focused exclusively on what it must be like to leave in a world in which error prone or malicious users didn't exist. That is to say I momentarily punted on the matter of user input validation. But data validation is so crucial to successful web application development that it can be put off no longer, and so this chapter is devoted entirely to the topic. In this chapter you'll learn all about Laravel's native validators, and how to incorporate form requests into your project to add form validation while ensuring your controller code remains lean.
Building and navigating table relations is an standard part of the development process even when working on the most unambitious of projects, yet this task is often painful when working with many web frameworks. Fortunately, using Laravel it's easy to define and traverse these relations. In this chapter I'll show you how to define, manage, and interact with one-to-one, one-to-many, many-to-many, has many through, and polymorphic relations.
Whether for requiring newly registered users to confirm their e-mail address, or notifying event attendees of scheduling changes, web applications such as HackerPair rely heavily on using e-mail as an efficient means of communication. In this chapter you'll learn about Laravel's `Mailable` class, a fantastic solution for generating e-mails within your application. You'll also learn how to test e-mail generation and delivery in a sane fashion. Just for added measure, I'll walk you through the steps I took to incorporate a contact form into HackerPair which when submitted sends inquiring users' messages and contact details to a support address.
Most modern applications offer user registration and preference management features in order to provide customized, persisted content and settings. In this chapter you'll learn how to integrate user registration, login, and account management capabilities into your Laravel application. I'll also show you to to add social authentication to your application, allowing users to authenticate using a variety of popular OAuth providers such as Twitter, Facebook, and GitHub.
Most web applications incorporate a restricted administration console accessible by the project developers and support team. In this chapter I'll show you an easy solution for designating certain users as administrators, and how to grant access to a restricted console using prefixed route grouping and custom middleware.
These days a web interface is often only one of several available vehicles for interacting with the underlying data. Popular services such as GitHub, Amazon, and Google also offer an API (Application Programming Interface) which allow enterprising developers to dream up and implement new ways to view, mine, and update these companies' vast data stores. In this chapter you'll learn how to create your own API, and provide registered users with an API key which they'll use to authenticate when interacting with the API.