πŸ”₯ Weekly thread #05 of 2022

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

A weekly thread 🧡

Laravel provides a `Fluent` class as a universal structure for array data

7

πŸ”₯ Laravel provides a `Fluent` class as a universal structure for array data

Laravel provides a `Fluent` class as a universal structure for array data

Fluent is a utility class provided by @laravelphp that lets us handle data fluently.

Out of the box it can be turned into an array or JSON, it can act as an array and it's serializable as a JSON.

It also gets and sets attributes dynamically and in a fluent way.

#Laravel #PHP

match() statements are a great way to clean up code

3

πŸ”₯ match() statements are a great way to clean up code

match() statements are a great way to clean up code

Match offers such a compact and clean syntax compared to its PHP alternatives 🌈

It can make our code way more readable and concise πŸ’…

#PHP

You can disable lazy loading using Model::preventLazyLoading()

2

πŸ”₯ You can disable lazy loading using Model::preventLazyLoading()

You can disable lazy loading using Model::preventLazyLoading()

πŸ”₯ #Laravel Tip: Protect your database from the dangers of lazy loading by disabling it in your Laravel app. You can also customise how violations are handled, which is perfect for models outside of your control e.g. within packages.

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