๐Ÿ”ฅ Weekly thread #08 of 2022

๐Ÿ”ฅ This week's code tips for Laravel developers

A weekly thread ๐Ÿงต

Use on-demand notifications to send messages to unregistered users

5

๐Ÿ”ฅ Use on-demand notifications to send messages to unregistered users

Use on-demand notifications to send messages to unregistered users

๐ŸŒถ๏ธ #Laravel tip: Sometimes you may need to send a notification to someone who is not stored as a "user" of your application.

Welcome to On-Demand Notifications in Laravel ๐Ÿ”ฅ

#PHP #Developers

Name *all* timestamp fields using the action_at convention

3

๐Ÿ”ฅ Name *all* timestamp fields using the action_at convention

Name *all* timestamp fields using the action_at convention

Laravel tip: Use the "{action}_at" naming convention for your DATETIME and TIMESTAMP fields.

This helps you to instantly recognise in your code when you're using a datetime field ๐Ÿ˜„

#laravel #php

Use the `WITH TIES` clause to return more than the `LIMIT`-ed amount when there are multiple results with the same value

2

๐Ÿ”ฅ Use the `WITH TIES` clause to return more than the `LIMIT`-ed amount when there are multiple results with the same value

Use the `WITH TIES` clause to return more than the `LIMIT`-ed amount when there are multiple results with the same value

โšก๏ธ Database Tip

Everyone knows the LIMIT clause. But what do you do if you want to have e.g. the employees with the TOP 3 salaries and not exclude the 4th or 5th one earning the same as the 3rd? The WITH TIES clause can return more results if the value is the same. Great!

Create Subscribers to listen to & handle multiple events using separate methods, inside a single class

1

๐Ÿ”ฅ Create Subscribers to listen to & handle multiple events using separate methods, inside a single class

Create Subscribers to listen to & handle multiple events using separate methods, inside a single class

Did you know that you can create a "Subscriber" class in Laravel to handle multiple events with different methods in one Listener class?

This is very useful if you want to group certain actions with the same dependencies.

Documentation: https://laravel.com/docs/9.x/events#event-subscribers

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