πŸ”₯ Weekly thread #14 of 2022

πŸ”₯ This week's code tips for Laravel developers

A weekly thread 🧡

You can temporarily disable timestamps when saving a model

6

πŸ”₯ You can temporarily disable timestamps when saving a model

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

You can create Storage disks on the fly

5

πŸ”₯ You can create Storage disks on the fly

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.

You can use the `missing` method to customize 404 handling on a route

4

πŸ”₯ You can use the `missing` method to customize 404 handling on a route

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.

You can call `withTrashed()` on a route to accept soft deleted models

2

πŸ”₯ You can call `withTrashed()` on a route to accept soft deleted models

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.

You can call `squish()` on Stringable instances to remove all unnecessary whitespaces

1

πŸ”₯ You can call `squish()` on Stringable instances to remove all unnecessary whitespaces

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 :)

We're writing a book, you can get it for free here.