mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 13:24:03 +00:00
Weekly thread #8
This commit is contained in:
parent
1a53831d4d
commit
6d630dcea8
11 changed files with 113 additions and 1 deletions
11
content/tips/create-methods-for-complex-conditionals.md
Normal file
11
content/tips/create-methods-for-complex-conditionals.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'Create methods for complex conditionals'
|
||||
tweet_id: '1498010809179332609'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: enunomaduro
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FMI11QtXMAUnCID.jpg'
|
||||
created_at: 2022-02-27T19:03:03+00:00
|
||||
slug: create-methods-for-complex-conditionals
|
||||
---
|
||||
Encapsulating complex conditionals offering a "callable" API is sexy AF. 🍑
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'Create Subscribers to listen to & handle multiple events using separate methods, inside a single class'
|
||||
tweet_id: '1498010791303282688'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: bobbybouwmann
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FMJNvELWYAs0iij.jpg'
|
||||
created_at: 2022-02-27T19:02:58+00:00
|
||||
slug: create-subscribers-to-listen-to-amp-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
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'Name *all* timestamp fields using the action_at convention'
|
||||
tweet_id: '1498010797083009025'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: AshAllenDesign
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLy78SOXsAMRB2g.jpg'
|
||||
created_at: 2022-02-27T19:03:00+00:00
|
||||
slug: 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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'Put migration names in quotes when running make:migration'
|
||||
tweet_id: '1498010806155235328'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: carre_sam
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FMDWVEAXEAcHEKE.jpg'
|
||||
created_at: 2022-02-27T19:03:02+00:00
|
||||
slug: put-migration-names-in-quotes-when-running-makemigration
|
||||
---
|
||||
👀 Laravel Tip: Save time when typing migration names by using quotes around the name!
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'Use on-demand notifications to send messages to unregistered users'
|
||||
tweet_id: '1498010803156381696'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: bhaidar
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKDorcxVQAEERjT.jpg'
|
||||
created_at: 2022-02-27T19:03:01+00:00
|
||||
slug: 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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'Use tap() to do something with the object and immediately return it'
|
||||
tweet_id: '1498010800098734081'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: enunomaduro
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FMMN_6wXsAMmS_e.jpg'
|
||||
created_at: 2022-02-27T19:03:01+00:00
|
||||
slug: use-tap-to-do-something-with-the-object-and-immediately-return-it
|
||||
---
|
||||
Use the @laravelphp's "tap()" function to do something with an object, and then return the object itself. 🧋
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 'Use the `WITH TIES` clause to return more than the `LIMIT`-ed amount when there are multiple results with the same value'
|
||||
tweet_id: '1498010794155380736'
|
||||
thread_slug: weekly-thread-2022-08
|
||||
author_username: tobias_petry
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FMSIa6kXsAQ2Axf.jpg'
|
||||
created_at: 2022-02-27T19:02:59+00:00
|
||||
slug: 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!
|
||||
Loading…
Add table
Add a link
Reference in a new issue