Intermediate

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.

Start Series For Free

Share this series on:

  • 01

    Episode 1 Run Time 4:21

    How Do I Restrict Access With Nginx Free

    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

    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.

  • 03

    Episode 3 Run Time 17:07

    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!

    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

    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.

  • 05

    Episode 5 Run Time 14:48

    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.

    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

    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.

    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

    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.

    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

    Help Me Understand When to Use Polymorphic Relations

    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

    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.

    View the completed source for this episode on GitHub.

  • 10

    Episode 10 Run Time 19:11

    How Do I Sort Tags By Letter

    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

    How Do I Dry Up My Forms

    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

    How Do I Automatically Resize Textareas to Fit Their Contents Free

    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

    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.

    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

    How Do I Create A Snippets App: Part 2

    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

    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?"