Upgrading Legacy Passwords With Laravel

I recently began to rebuild a legacy application using Laravel. I soon ran into a problem: the passwords stored in the database were using an old SHA hashing mechanism. I didn't want to bother existing users to enter a new password, so I wanted to easily upgrade the passwords without causing these users any trouble. The problem is that you can't backtrack their passwords, so just rehashing them isn't an option. How do you go about doing this? Let me show you what I came up with.

Read more

Implementing A Page View Counter In Laravel

Implementing a page view counter into your Laravel application seems like the easiest job at first. Just add a column in your database with the current view count and increment that on every page load, right? Well, there's a little more to it: This will cause the counter to increment on every page load, even when the user refreshes the page or subsequently visits the page in a short amount of time. This usually isn't the desired behavior, so let's look into solving this issue. In particular, we will be making use of Events and Route Filters to achieve this. Let's walk through the process of creating this using an incremental approach.

Read more

Extending The Connection Class In Laravel

Sometimes you may wish to extend the database Connection class in Laravel. Maybe you want to customize the internal workings. In my case I needed to alter the database results for every query, whether it's through the Fluent Query Builder or Eloquent. I needed to do this to make my package, Laravel DB Normalizer, work as smoothly as possible.

Read more