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!
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.
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!
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.
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.
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.
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.
Help Me Understand When to Use Polymorphic Relations
Polymorphic relations are a tricky thing. When exactly should we reach for them again?
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.
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.
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?
How Do I Automatically Resize Textareas to Fit Their Contents
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!
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.
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.
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?"
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.
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.
There are currently no items in your shopping cart.