Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Browse all 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.

Progress

Series Info

Episodes
25
Run Time
5h 33m
Difficulty
Intermediate
Last Updated
Oct 22, 2019
Version
Latest

Series Episodes

  1. Episodes (25)
    1. How Do I Restrict Access With Nginx

      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!
    2. How Do I Distribute an NPM Package Written With ES2015

      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.
    3. How Do I Use Iterators

      "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!
    4. How Should I Name My Events and Listeners?

      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.
    5. How Do I Unit Test Eloquent Models?

      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.
    6. Help Me Understand CSRF

      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.
    7. How Do I Fetch the Most Recent Reply's Username

      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.
    8. Help Me Understand When to Use Polymorphic Relations

      Polymorphic relations are a tricky thing. When exactly should we reach for them again?
    9. How Do I Create Nested Comments

      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.
    10. How Do I Sort Tags By Letter

      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.
    11. How Do I Create A Snippets App: Part 1

      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.
    12. How Do I Convert Switch Statements to Polymorphism

      Today's topic comes courtesy of Diaz, who asks, "How do I convert messy switch statements to use polymorphism and factories?"
    13. How Do I Reference Objects Like Arrays

      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.
    14. How Do I Impersonate Users

      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.
    15. How to Cleanly Refactor Loops

      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.
    16. How Do I Make One Interface Fit Another

      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.
    17. Contribute to Laravel: From Start to PR

      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?
    18. How Do I Create Laravel Macros

      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.
    19. How Do I Create a Star-Rating System: Part 1

      A user on the Laracasts forum recently requested help creating a star-rating system. You've surely seen these many times: choose from one to five stars, and your score will be included in the overall average rating. Let's learn how to build such a component over the next two episodes. We'll start on the backend by fleshing out our desired API.
    20. How Do I Create a Star-Rating System: Part 3

      With the backend portion tested and ready to go, the only remaining step is to switch to the frontend. In this lesson, we'll build a star-rating Vue component that submits an AJAX request to the server each time the user chooses a rating of 1-5.
    21. How Do I Make a Floating Nav Bar

      You've surely seen this functionality all over the web: you scroll the page a bit, and suddenly the navigation bar slides back into view and "stickies" itself to the top of the page. We can use an IntersectionObserver to make a similar effect. This JavaScript API allows us to pass a callback function that will be triggered each time a target element intersects the root viewport. In this lesson, I'll show you exactly how to code it up.

Continue Learning