Fresh code snippets, straight from my codebase to yours.

Using $fillable for validationLaravel

The "fillable" property on your Eloquent models might just be a sensible place to put your validation logic. After all, given how this list is practically part of validation, it would be a waste not to use that same structure for defining the rules respectively.

What's the best session lifetime?Laravel

There has been some debate over the recommended lifetime for a session. While some argue it has little effect on security, others claim the shorter, the better. Personally, I think the answer lies somewhere in between.

Easy Dark Mode TogglerLaravel

If you're also a fan of both the Laravel TALL stack and Dark Mode, then this one is for you. In just three simple steps, we will add an elegant way of adding support for Dark Mode into our Laravel application. Whether Taylor likes it or not ;-)

Renaming "Teams" in Laravel JetstreamLaravel

While Laravel Jetstream doesn't provide an easy way of renaming the "Team" noun into something like "Project", there is actually a relatively easy way to achieve this. No need to refactor every model or database table if there is a middle road.

Using models for dataLaravel

Although most of the time we want to store data inside of our database and use our models to represent that data in an object-oriented way, there might be times when you want an Eloquent model specifically for data.

Converting Variables to ValuesLaravel

Have you ever found yourself wanting to replace certain variables in a string? Well, then this relatively small helper function might just be what you're looking for. It converts variables inside of a string into actual values.

Sort by arrayLaravel

This method for Laravel Eloquent is used to sort items by array keys, which can be useful when you want to run by a number of possible scenarios and assign priority based on the array's occurance.

Laravel ID normalizerLaravel

Although Laravel makes use of the "id" column name by default, I have encountered projects where this column name was named differently. Instead of remembering primary keys, why not normalize them?

Just, send an emailLaravel

Through the years it seems like Laravel has frequently changed its mind on how to send emails. This example shows the most basic way to send an email without having to rely on envelopes, addresses, factories or actions.

Newing up models, in styleLaravel

Although my recent submission for this idea to be integrated into the Laravel Framework was not particularly a popular request, I thought it might still interest others.

Poor man's cachingPHP

Although there are many solutions out there when it comes to caching, I have found a few occassions where it was actually as straight-forward as a single line of code.

Laravel error-safe methodsLaravel

A few small, yet powerful methods for writing error-safe logic, similar to the native PHP null-safe operator used for strings. Although a sharp knife, it can be useful in a few situations.