🔥 Weekly thread #24 of 2022

🔥 This week's code tips for Laravel developers

A weekly thread 🧵

You can customize default validation rules for passwords

9

🔥 You can customize default validation rules for passwords

You can customize default validation rules for passwords

You can specify the default validation rules for passwords in a single location of your Laravel app 🔐

Create a custom provider or use the AppServiceProvider. Then use Password::defaults() as validation rule ✅

You can have different defaults depending on the app environment.

You can namespace your helper functions

7

🔥 You can namespace your helper functions

You can namespace your helper functions

🔥 Namespaced functions are a good way to make use of helper functions, while avoiding conflicts in the global namespace

You can import entire namespaces in PHP

4

🔥 You can import entire namespaces in PHP

You can import entire namespaces in PHP

🔥 You can import entire namespaces in PHP

This is useful when you're interacting with many classes from a single namespace

You can add a URI fragment when redirecting to a route

3

🔥 You can add a URI fragment when redirecting to a route

You can add a URI fragment when redirecting to a route

You can add a URI fragment when redirecting to a route in Laravel.

This is super useful when redirecting to a specific section of the page. E.g. reviews section on a product page 📈

Uploaded files can be attached to emails directly from the request

1

🔥 Uploaded files can be attached to emails directly from the request

Uploaded files can be attached to emails directly from the request

Sending emails with user uploaded files in Laravel?

Did you know you don't have to save the file first — you can simply attach the uploaded file with attachData 💌 📸

Here's a snippet from a Mailable class using it.

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