Back Button PHP

How Do I

It's cool, we all hit road blocks from time to time. Have a web-related question that could be solved in ten minutes or less as a video? If so, tweet @laracasts, hash #helpMeLaracasts, and cross your fingers! You just might see your answer in this series.

Intermediate
Difficulty
21 episodes
4:38:51 hrs
Start Series

How Do I

It's cool, we all hit road blocks from time to time. Have a web-related question that could be solved in ten minutes or less as a video? If so, tweet @laracasts, hash #helpMeLaracasts, and cross your fingers! You just might see your answer in this series.

  • Latest Episode: How Do I Create Laravel Macros

  • Like this series? Share the love!

  • 01

    Episode 1 Run Time 4:21

    The very first #helpMeLaracasts question in this series comes from Mohammad, via email. He'd like to know how to restrict access to his website on the server level, using Nginx. Maybe his code has been pushed to production, but he's not quite ready to let the public see it. Okay, let's figure out what to do!

  • 02

    Episode 2 Run Time 5:44

    Today's question is locked on the Node world. Imagine that you're building an NPM package, but are hoping to use the latest and greatest that ES2015 has to offer. Is it possible to use all these modern features, while ultimately distributing a compiled version to all users? Of course! I'll show you how.

  • 03

    Episode 3 Run Time 17:07

    "Iterator" is a scary term, but it's not so hard to understand. You already know that you can iterate (with foreach) over an array. But what about things which are not arrays? Maybe you're dealing with a collection class, or a file reader, or a database query. How do we iterate over these sorts of things? Well, easily!

    View the source for this lesson on GitHub.

    Thanks so much to Jigal Sanders for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 04

    Episode 4 Run Time 13:23

    This episode's question comes via email. Everybody names their event listeners differently. Let's talk about it, as I offer one approach that you might consider. Don't add the Listener suffix to your class names; instead, name them in exactly the way that you would speak of them.

    Thanks so much to Sarah Mallicote for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 05

    Episode 5 Run Time 14:48

    So how are you supposed to unit test Eloquent models again? You're not the first person to ask this question. The answer is, well, you don't! In this lesson, I'll demonstrate exactly how I go about it.

    Thanks so much to Bart Jacobs for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 06

    Episode 6 Run Time 21:51

    It's possible that the extent of your CSRF (Cross-Site Request Forgery) knowledge equates to, "If I add a call to csrf_field() in my forms, Laravel keeps me safe from bad guys." And that's fine; you're not wrong! However, if you'd like to really dig in to see how all the pieces fit together, and why we must protect ourselves from this sort of attack, here is the video for you.

    Thanks so much to Caleb Cruz for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 07

    Episode 7 Run Time 11:17

    So you have a single post model, and you want to fetch the username of the most recently published comment. How exactly do we do that? Well, I'll show you a few techniques you might use, ranging from adding a hasOne relationship, to leveraging the law of demeter, to applying simple joins.

    Thanks so much to Wadday Hassan for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 08

    Episode 8 Run Time 24:10

    Polymorphic relations are a tricky thing. When exactly should we reach for them again?

    View the source for this lesson on GitHub.

    Thanks so much to @shahsahebi for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 09

    Episode 9 Run Time 27:44

    In this episode, I'll demonstrate how to create nested comments, much like you'd find on Reddit or Disqus. This will give us a good excuse to review a wide variety of Eloquent and collection techniques that you can tuck into your daily workflow.

    View the completed source for this episode on GitHub.

  • 10

    Episode 10 Run Time 19:11

    So you'd like to offer a page on your website that allows users to view all tags, organized by letter? No problem; I'll show you how. This will also give us a nice opportunity to a few fun things, including Bulma, CSS columns, and Eloquent collections.

    Thanks so much to Phillip for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

    View the source for this episode on GitHub.

  • 11

    Episode 11 Run Time 15:42

    A common gotcha for beginners revolves around re-using forms. It doesn't feel quite right to copy and paste your model's "create" form into the "edit" page, but you're not sure of any other way. For the "edit" form, a couple of things must be different: the submit button should have unique text, and each input should display the old value from the session or the saved value in the database. So how exactly do we allow for this, without breaking the "create" page?

    View the source for this lesson on GitHub.

    Thanks so much to Mason for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 12

    Episode 12 Run Time 3:26

    Imagine that you have a forum, and need to dynamically resize textareas to fit the length of each user's reply. That way, should they need to edit their reply, they won't have to manually expand the textarea to view their long comment. For things such as this, I like to use a package, called autosize. I'll show you how; it's easy!

    Thanks so much to Jacob for the question. If the rest of you have any questions that could be answered in video-form, tweet your question and add the hash tag, #helpMeLaracasts.

  • 13

    Episode 13 Run Time 18:59

    Over the next two episodes, we'll build a primitive code snippets application that allows users to "fork" existing snippets, and then expand upon them. We'll also set up the necessary functionality to track and list all forks for a given snippet.

    To begin, we'll create a new Laravel 5.4 project, and flesh out the initial structure of the application.

  • 14

    Episode 14 Run Time 11:33

    In this second part, we'll first implement the necessary functionality to allow users to "fork" existing snippets. Then, we'll apply syntax highlighting (using highlight.js), and wrap up our project. View the source for this two-part lesson on GitHub.

    Homework: Clone this project, and begin extending it with your own features. Here are some ideas to get you started:

    1. Add user registration, and associate each snippet with an owning user.
    2. Allow users to view only their snippets.
    3. Add a "like" button to each snippet, and list users in sidebar by those who have the most snippet likes.
    4. Add a "language" column to allow for better sorting.
  • 15

    Episode 15 Run Time 11:00

    Today's topic comes courtesy of Diaz, who asks, "How do I convert messy switch statements to use polymorphism and factories?"

  • 16

    Episode 16 Run Time 4:31

    From time to time, you may find yourself in the position of needing to interact with an object's data as if it's an array. The solution is to implement PHP's ArrayAccess interface. I'll show you how in this episode.

  • 17

    Episode 17 Run Time 11:47

    In this episode, we'll review how to impersonate users in your application. From time to time, you'll find that it's useful to have the ability to see a particular error or issue exactly as the user does. We'll review the basic implementation, as well as how to test and secure this very sensitive route.

    View the source for this lesson on GitHub.

  • 18

    Episode 18 Run Time 13:02

    In this episode, we'll review a few collection-based refactoring steps, for iterating over a particular list of data. We'll begin with the common approach, and then slowly tweak things, bit by bit, to improve readability.

    I encourage you to give Refactoring to Collections a read to dig deeper.

  • 19

    Episode 19 Run Time 7:29

    From time to time, you'll find yourself in the position of needing to adapt one interface - that you don't control - to fit another. Adapt is the keyword in that sentence. In this episode, you'll learn how to use the adapter pattern to solve this common problem.

  • 20

    Episode 20 Run Time 8:57

    Those who regularly contribute to open source projects may forget that getting started with your first PR can be incredibly confusing? Where do you even start? Fork? PR? Huh?

    In this episode, from scratch, we'll identify a small patch that we'd like to make to the Laravel codebase, and then walk through the steps of applying it, testing it, and then submitting a pull request to the Laravel repository on GitHub.

  • 21

    Episode 21 Run Time 12:49

    If you hunt around the Laravel framework source code, you'll find frequent references to a trait called Macroable. This allows you to dynamically extend the surface area of a given class. In this lesson, I'll demonstrate how to create your own macros, and review how everything is wired behind the scenes to make this particular functionality possible.