Back Button Laravel

Laravel 6 From Scratch

laravelfromscratch.com

In this series, step by step, I'll show you how to build web applications with Laravel 6. We'll start with the basics and incrementally dig deeper and deeper, as we review real-life examples. Once complete, you should have all the tools you need. Let's get to work!

Intermediate
Difficulty
29 episodes
2:27:31 hrs
Start Series
  1. Section 1 Prerequisites

    1. Run Time 2:40 Free

      Before we dig into the nuts and bolts of Laravel, let's first zoom out and discuss what exactly happens when a request comes in.

    2. Before we get started, you must first ensure that up-to-date versions of both PHP and MySQL are installed and available on your machine. In this episode, we'll review how to go about this. Once complete, we can then install Composer.

    3. Run Time 3:02 Free

      Now that we have Composer setup, we can pull in the Laravel installer and make it accessible globally on our machine. This allows you to run a single command to build a fresh Laravel installation: laravel new app.

    4. Run Time 3:18 Free

      If you're a Mac user, rather than running php artisan serve, you might instead choose to install Laravel Valet. Valet is a blazing fast development environment for Laravel that's a cinch to setup.

  2. Section 2 Routing

    1. Run Time 3:41 Free

      When I learn a new framework, the first thing I do is figure out how the framework's default splash page is loaded. Let's work through it together. Our first stop is routes/web.php.

    2. Run Time 4:11 Free

      The request() helper function can be used to fetch data from any GET or POST request. In this episode, we'll learn how to fetch data from the query-string, pass it to a view, and then encode it to protected against potential XSS attacks.

    3. Run Time 3:42 Free

      Often, you'll need to construct a route that accepts a wildcard value. For example, when viewing a specific post, part of the URI will need to be unique. In these cases, we can reach for a route wildcard.

    4. Run Time 3:01 Free

      It's neat that we can provide a closure to handle any route's logic, however, you might find that for more sizable projects, you'll almost always reach for a dedicated controller instead. Let's learn how in this lesson.

  3. Section 3 Database Access

    1. So far, we've been using a simple array as our data store. This isn't very realistic, so let's learn how to set up a database connection. In this episode, we'll discuss environment variables, configuration files, and the query builder.

    2. Run Time 3:45 Free

      In the previous episode, we used the query builder to fetch the relevant post from the database. However, there's a second option we should consider: Eloquent. Not only does an Eloquent class provide the same clean API for querying your database, but it's also the perfect place to store any appropriate business logic.

    3. Run Time 5:23 Free

      In a previous episode, we manually created a database table; however, this doesn't reflect the typical workflow you'll follow in your day-to-day coding. Instead, you'll more typically reach for migration classes. In this episode, we'll discuss what they are and why they're useful.

    4. It can quickly become tedious to generate all the various files you need. "Let's make a model, and now a migration, and now a controller." Instead, we can generate everything we need in a single command. I'll show you how in this episode.

    5. Run Time 7:36 Free

      When possible, the code you write should reflect the manner in which you speak about the product in real life. For example, if you run a school and need a way for students to complete assignments, let's work those terms into the code. Perhaps you should have an Assignment model that includes a complete() method.

  4. Section 4 Views

    1. Run Time 4:11 Free

      If you review the welcome view that ships with Laravel, it contains the full HTML structure all the way up to the doctype. This is fine for a demo page, but in real life, you'll instead reach for layout files.

    2. Run Time 4:27 Free

      Using the techniques you've learned in the last several episodes, let's integrate a free site template into our Laravel project, called SimpleWork.

    3. Run Time 2:15 Free

      In this episode, you'll learn how to detect and highlight the current page in your navigation bar. We can use the Request facade for this.

    4. Laravel provides a useful tool called Mix - a wrapper around webpack - to assist with asset bundling and compilation. In this episode, I'll show you the basic workflow you'll follow when working on your frontend.

    5. Run Time 6:19 Free

      Let's next learn how to render dynamic data. The "about" page of the site template we're using contains a list of articles. Let's create a model for these, store some records in the database, and then render them dynamically on the page.

    6. Let's finish up this exercise by creating a dedicated page for viewing a full article.

    7. Run Time 2:45 Free

      Let's review the solution to the homework from the end of the previous episode. To display a list of articles, you'll need to create a matching route, a corresponding controller action, and the view to iterate over the articles and render them on the page.

  5. Section 5 Forms

    1. There are seven restful controller actions that you should become familiar with. In this episode, we'll review their names and when you would reach for them.

    2. Run Time 7:37 Free

      Now that you're familiar with resourceful controllers, let's switch back to the routing layer and review a RESTful approach for constructing URIs and communicating intent.

    3. Run Time 7:55 Free

      Now that you understand resourceful controllers and HTTP verbs, let's build a form to persist a new article.

    4. Browsers, at the time of this writing, only recognize GET and POST request types. No problem, though; we can get around this limitation by passing a hidden input along with our request that signals to Laravel which HTTP verb we actually want. Let's review the basic workflow in this episode.

    5. Run Time 8:53 Free

      Before we move on to cleaning up the controller, let's first take a moment to review form validation. At the moment, our controller doesn't care what the user types into each input. We assign each provided value to a property and attempt to throw it in the database. You should never do this. Remember: when dealing with user-provided data, assume that they're being malicious.

  6. Section 6 Controller Techniques

    1. So far. we've been manually fetching a record from the database using a wildcard from the URI. However, Laravel can perform this query for us automatically, thanks to route model binding.

    2. Run Time 5:40 Free

      Your next technique is to reduce duplication. If you review our currentArticlesController, we reference request keys in multiple places. Now as it turns out, there's a useful way to reduce this repetition considerably.

    3. Run Time 3:58 Free

      Named routes allow you to translate a URI into a variable. This way, if a route changes at some point down the road, all of your links will automatically update, due to the fact that they're referencing the named version of the route rather than the hardcoded path.

  7. Section 7 Eloquent

    1. Let's now switch back to Eloquent and begin discussing relationships. For example, if I have a $user instance, how might I fetch all projects that were created by that user? Or if I instead have a $project instance, how would I fetch the user who manages that project?

      For a deeper dive, please review the Eloquent Relationships Laracasts series.

Series still in development robot

*Series still in development. Check back often for updates.