8
7
π₯ You can create DB indices for transformed versions of columns
β‘οΈ Database Tip
Most developers are puzzled that indexes are not used for e.g. WHERE LOWER(email) = ?. But contrary to common belief, an index can be created for these cases! It's called a function-based index and is supported by MySQL and PostgreSQL.
6
π₯ You can temporarily disable timestamps when saving a model
π #Laravel Tip | In some cases you don't want the updated_at field the change when updating small things. .. Did you know you could disable the timestamps while saving your data? Here is how... π₯
#laraveltip #php #code #development #details
5
π₯ You can create Storage disks on the fly
π₯ Did you know that you can create Storage disks on the fly in @laravelphp? This is super useful when you want your user to provide their own filesystem credentials, e.g. a user can bring their own S3 bucket to your app.
4
π₯ You can use the `missing` method to customize 404 handling on a route
π₯ Laravel tip: Customizing Missing Model Behavior in route model bindings
By default, Laravel throws a 404 error when it can't bind the model, but you can change that behavior by passing a closure to the missing method.
3
π₯ You can calculate the `age()` of Carbon instances
#TIL How to calculate the age using a date in Laravel or using Carbon.
#LaravelTip #PHPTip #dev
2
π₯ You can call `withTrashed()` on a route to accept soft deleted models
π₯ Laravel Tip: Route model binding soft-deleted models
By default, when using route model binding will not retrieve models that have been soft-deleted.
You can change that behavior by using withTrashed
in your route.
1
π₯ You can call `squish()` on Stringable instances to remove all unnecessary whitespaces
π₯ #Laravel Tip: Hot off the press, the latest release includes the βsquishβ global helper method by @DwightConrad. It removes all extraneous white space from a string, including between words. Itβs like βtrimβ on steroids :)