πŸ”₯ Weekly thread #03 of 2022

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

A weekly thread 🧡

Laravel's Http client supports concurrent requests using the `pool` method

10

πŸ”₯ Laravel's Http client supports concurrent requests using the `pool` method

Laravel's Http client supports concurrent requests using the `pool` method

πŸ”₯ #Laravel Tip: Need to make more than one HTTP request e.g. to one or more sites? You might think about running them concurrently to improve performance. The HTTP client's 'pool' method makes this a trivial exercise.

MySQL has a blackhole store engine

9

πŸ”₯ MySQL has a blackhole store engine

MySQL has a blackhole store engine

πŸ‘¨β€πŸ”¬ Cool MySQL hack:

🧐 If your staging env has a table that ideally doesn't have data in it (esp production data)

πŸ•³ You can make it a BLACKHOLE table

πŸ˜… I used this to make sure a table with a list of emails to send never contains any rows. Because, you know....

Interesting technique: add getters to Form Requests

7

πŸ”₯ Interesting technique: add getters to Form Requests

Interesting technique: add getters to Form Requests

πŸ’ͺPower up your #Laravel requests

You can add very simple getters on the request, so: βœ…You actually know what's on the request βœ…You have types βœ…You can do basic data transformation

Specify the columns you want to select when fetching all() models

6

πŸ”₯ Specify the columns you want to select when fetching all() models

Specify the columns you want to select when fetching all() models

🌢️ #Laravel tip: You can select the columns to run when using the Model::all() method. No need for an additional select() method.

A tiny tip to always keep in mind πŸ’‘

#PHP #Developers

Make models prunable to periodically delete them from the DB

3

πŸ”₯ Make models prunable to periodically delete them from the DB

Make models prunable to periodically delete them from the DB

πŸ’‘#Laravel Eloquent Tip

Laravel 8 introduced the Prunable trait. You can use it to delete old models on a scheduled basis.

You don't need to write custom commands anymore:

You can name migrations "like this"

2

πŸ”₯ You can name migrations "like this"

You can name migrations "like this"

πŸ”₯ Epic Laravel Tip - Did you know that you don't necessarily have to use underscores for migrations names?

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