1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 05:14:04 +00:00

Week 35/2022 (#32)

This commit is contained in:
lukinovec 2022-12-01 12:24:35 +01:00 committed by GitHub
parent 646b0dc35f
commit 2d53681753
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 136 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
username: DanSysAnalyst
name: 'Dan 🇺🇦'
avatar: 'https://pbs.twimg.com/profile_images/1378978815712628737/V2q0dtWi_normal.jpg'
---

View file

@ -0,0 +1,5 @@
---
username: PovilasKorop
name: 'Povilas Korop | Laravel Courses Creator & Youtuber'
avatar: 'https://pbs.twimg.com/profile_images/1576085948743524352/JQ-gfbyf_normal.jpg'
---

View file

@ -1,5 +1,5 @@
---
username: enunomaduro
avatar: 'https://pbs.twimg.com/profile_images/1514432896102109185/LMj2oeW8_normal.jpg'
name: 'Nuno Maduro 🤌🏻'
avatar: 'https://pbs.twimg.com/profile_images/1573244584943042560/9Mq8p_QH_normal.jpg'
name: 'nuno maduro 🤌🏻'
---

View file

@ -1,5 +1,5 @@
---
username: freekmurze
avatar: 'https://pbs.twimg.com/profile_images/1492514213381746692/DARB_SUs_normal.jpg'
avatar: 'https://pbs.twimg.com/profile_images/1578325143356678146/sf9MoAbW_normal.jpg'
name: 'Freek Van der Herten 🔭'
---

View file

@ -0,0 +1,13 @@
---
slug: weekly-thread-2022-35
title: 'Weekly thread #35 of 2022'
tweet_id: '1596508349322866688'
author_username: archtechx
created_at: 2022-11-26T14:17:06+00:00
links: { }
---
🔥 We're back to posting our threads!
In our news thread (will be posted shortly after this one), I'll share some updates about Tenancy v4 and our content schedule
In the meantime: Best Laravel tips from the past few months 👇

View file

@ -0,0 +1,11 @@
---
title: '`Str::mask()` lets you mask a portion of a string with a character (e.g. *)'
tweet_id: '1596508370952855553'
thread_slug: weekly-thread-2022-35
author_username: PovilasKorop
images:
- 'https://pbs.twimg.com/media/FhCmZ9IX0AAiTED.jpg'
created_at: 2022-11-26T14:17:11+00:00
slug: strmask-lets-you-mask-a-portion-of-a-string-with-a-character-eg
---
Laravel tip. From Laravel 8.69, there's a "Str::mask()" method which masks a portion of the string with a repeated character like "*".

View file

@ -0,0 +1,13 @@
---
title: 'Use `composer outdated --direct` to view outdated dependencies of your app'
tweet_id: '1596508368146817030'
thread_slug: weekly-thread-2022-35
author_username: freekmurze
images:
- 'https://pbs.twimg.com/media/FfXlKEyWAAcxHaQ.jpg'
created_at: 2022-11-26T14:17:11+00:00
slug: use-composer-outdated-direct-to-view-outdated-dependencies-of-your-app
---
Using `composer outdated —direct` you can view any dependency of your app that has a major / minor / patch release available.
Heres the output for the Laravel app that powers https://freek.dev

View file

@ -0,0 +1,15 @@
---
title: 'You can create a special index for a transformation of a column'
tweet_id: '1596508360001482753'
thread_slug: weekly-thread-2022-35
author_username: tobias_petry
images:
- 'https://pbs.twimg.com/media/FdvFZNTXwAAwzV6.jpg'
created_at: 2022-11-26T14:17:09+00:00
slug: you-can-create-a-special-index-for-a-transformation-of-a-column
---
⚡️ Database Tip
Most developers are puzzled that indexes are not used for e.g. WHERE LOWER(email) = ?. But contrary to common belief, an index can be created for these cases! It's called a function-based index and is supported by MySQL and PostgreSQL.
https://sqlfordevs.com/function-based-index

View file

@ -0,0 +1,11 @@
---
title: 'You can echo backed enums in Blade'
tweet_id: '1596508357317185536'
thread_slug: weekly-thread-2022-35
author_username: enunomaduro
images:
- 'https://pbs.twimg.com/media/FeQJefMXEAEnOON.jpg'
created_at: 2022-11-26T14:17:08+00:00
slug: you-can-echo-backed-enums-in-blade
---
Papercut: starting today's @laravelphp release, Blade can now infer values from PHP 8.1 backed enums. 💅🏻

View file

@ -0,0 +1,15 @@
---
title: 'You can run your tests in a random order'
tweet_id: '1596508351872917504'
thread_slug: weekly-thread-2022-35
author_username: DanSysAnalyst
images:
- 'https://pbs.twimg.com/media/FbeprM_XoAEDnVJ.jpg'
created_at: 2022-11-26T14:17:07+00:00
slug: you-can-run-your-tests-in-a-random-order
---
🙂🙃🙂 Have you ever tried running your tests in random order?
This can be helpful to detect interdependencies between tests.
(works on @pestphp and PHPUnit)

View file

@ -0,0 +1,13 @@
---
title: 'You can temporarily disable an index by making it INVISIBLE'
tweet_id: '1596508362643865600'
thread_slug: weekly-thread-2022-35
author_username: tobias_petry
images:
- 'https://pbs.twimg.com/media/Fcmcb3wWQAELfyk.jpg'
created_at: 2022-11-26T14:17:10+00:00
slug: you-can-temporarily-disable-an-index-by-making-it-invisible
---
⚡️ Database Tip
Deleting an unused index is still a risky operation: If you are wrong (and it is still needed) the database will become slow. Before deleting it, you can make the index invisible first and make it visible again instantly if you still need it.

View file

@ -0,0 +1,17 @@
---
title: 'You can use a partial index to enforce uniqueness in tables that can have soft-deleted records'
tweet_id: '1596508365370191873'
thread_slug: weekly-thread-2022-35
author_username: tobias_petry
images:
- 'https://pbs.twimg.com/media/FhHXgF4XoAAHwU3.jpg'
created_at: 2022-11-26T14:17:10+00:00
slug: you-can-use-a-partial-index-to-enforce-uniqueness-in-tables-that-can-have-soft-deleted-records
---
⚡️ Database Tip
Unique indexes can not be created in some cases because a value is duplicated by e.g. soft-deleted rows.
But with partial indexes and creative tricks you can exclude some rows to create the uniqueness constraint on a selection of rows.
https://sqlfordevs.com/unique-index-ignore-some-rows

View file

@ -0,0 +1,15 @@
---
title: 'You can use backticks (``) to execute a shell command in PHP'
tweet_id: '1596508354536304640'
thread_slug: weekly-thread-2022-35
author_username: freekmurze
images:
- 'https://pbs.twimg.com/media/FbbpXeyWIAAR40j.jpg'
created_at: 2022-11-26T14:17:08+00:00
slug: you-can-use-backticks-to-execute-a-shell-command-in-php
---
🐘 Can you believe I didnt know that PHP has a backtick operator?
Anything between `` will be executed like shell_exec and returned 🤯
Docs: https://www.php.net/manual/en/language.operators.execution.php