1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00

Weekly thread #47

This commit is contained in:
lukinovec 2021-11-26 16:21:56 +01:00
parent 95735fb3c3
commit 5267f948b5
10 changed files with 106 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
username: RBilloir
name: 'Romain ''Maz'' BILLOIR'
avatar: 'https://pbs.twimg.com/profile_images/1154617719330922498/93xUoei7_normal.jpg'
---

View file

@ -1,5 +1,5 @@
--- ---
username: mattkingshott username: mattkingshott
name: 'Matt Kingshott 🏝' name: 'Matt Kingshott 🚀'
avatar: 'https://pbs.twimg.com/profile_images/1444979706571415564/toC9_E-T_normal.jpg' avatar: 'https://pbs.twimg.com/profile_images/1444979706571415564/toC9_E-T_normal.jpg'
--- ---

View file

@ -0,0 +1,11 @@
---
slug: weekly-thread-2021-47
title: 'Weekly thread #47 of 2021'
tweet_id: '1464247621518651392'
author_username: archtechx
created_at: 2021-11-26T15:16:37+00:00
links: { }
---
🔥 This week's code tips for Laravel developers
A weekly thread 🧵

View file

@ -0,0 +1,11 @@
---
title: 'Consider using mb_* functions when working with localized strings'
tweet_id: '1464247627696918528'
thread_slug: weekly-thread-2021-47
author_username: jbrooksuk
images:
- 'https://pbs.twimg.com/media/FEzpA84X0AALH07.jpg'
created_at: 2021-11-26T15:00:13+00:00
slug: consider-using-mb-functions-when-working-with-localized-strings
---
Not sure on the difference between "strtoupper" and "mb_strtoupper"? #PHP

View file

@ -0,0 +1,11 @@
---
title: 'Create an attempt() helper for calls that can silently fail'
tweet_id: '1464247622558896129'
thread_slug: weekly-thread-2021-47
author_username: mattkingshott
images:
- 'https://pbs.twimg.com/media/FE9oLAyX0AAhIM8.jpg'
created_at: 2021-11-26T15:00:12+00:00
slug: create-an-attempt-helper-for-calls-that-can-silently-fail
---
💡#Laravel Tip: Here's a useful little helper for when you need to run some code, but don't really need to handle any exceptions it might generate.

View file

@ -0,0 +1,11 @@
---
title: 'Laravel can automatically notify you by email when a scheduled job fails'
tweet_id: '1464247630377021448'
thread_slug: weekly-thread-2021-47
author_username: mattkingshott
images:
- 'https://pbs.twimg.com/media/FE3z7XuXsAA-RJk.jpg'
created_at: 2021-11-26T15:00:14+00:00
slug: laravel-can-automatically-notify-you-by-email-when-a-scheduled-job-fails
---
💡#Laravel Tip: Did you know that any commands you schedule in the console kernel can automatically email their output if something goes wrong.

View file

@ -0,0 +1,13 @@
---
title: 'Use aggregate methods to count related models'
tweet_id: '1464247626405060616'
thread_slug: weekly-thread-2021-47
author_username: alexjgarrett
images:
- 'https://pbs.twimg.com/media/FEy-iNNX0AYjL56.jpg'
created_at: 2021-11-26T15:00:13+00:00
slug: use-aggregate-methods-to-count-related-models
---
When you're counting related models in @laravelphp, opt for aggregates!
👎 Using the count() method on a collection of related models is a tad slower.

View file

@ -0,0 +1,13 @@
---
title: 'Use prefetching to boost the perceived speed of Livewire apps'
tweet_id: '1464247623796232193'
thread_slug: weekly-thread-2021-47
author_username: alexjgarrett
images:
- 'https://pbs.twimg.com/media/FE9K7s_X0AMvYbA.jpg'
created_at: 2021-11-26T15:00:12+00:00
slug: use-prefetching-to-boost-the-perceived-speed-of-livewire-apps
---
To boost perceived speed in your @LaravelLivewire apps when loading data, make use of prefetching.
The .prefetch modifier tells Livewire to fetch the result in the background on *hover*, and then displays the result when the button is actually clicked ✨

View file

@ -0,0 +1,15 @@
---
title: 'You can convert Eloquent Collections back to a Query Builder instance'
tweet_id: '1464247625046114305'
thread_slug: weekly-thread-2021-47
author_username: RBilloir
images:
- 'https://pbs.twimg.com/media/FEvymV7XsAE3Vv2.png'
created_at: 2021-11-26T15:00:12+00:00
slug: you-can-convert-eloquent-collections-back-to-a-query-builder-instance
---
A tiny tip about #laravel eloquent.
To retrieve the Query Builder after filtering the results: you can use `->toQuery()`.
The method internally use the first model of the collection and a `whereKey` comparison on the Collection models.

View file

@ -0,0 +1,15 @@
---
title: 'You can implement the ShouldBeEncrypted interface on your jobs to encrypt their payload before they get pushed to the queue'
tweet_id: '1464247629030703108'
thread_slug: weekly-thread-2021-47
author_username: pascalbaljet
images:
- 'https://pbs.twimg.com/media/FEyahMTXoAAv8gH.jpg'
created_at: 2021-11-26T15:00:13+00:00
slug: you-can-implement-the-shouldbeencrypted-interface-on-your-jobs-to-encrypt-their-payload-before-they-get-pushed-to-the-queue
---
💡 Since @laravelphp v8.19, there is a ShouldBeEncrypted interface that jobs can implement. This encrypts the payload, for example, in case the properties hold sensitive data.
As of v8.25, this works for Listeners, Mailables, and Notifications as well 💫
#Laravel #PHP #webdev https://twitter.com/pascalbaljet/status/1462711618329055232