mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
Week 24/2022
This commit is contained in:
parent
bd6a684102
commit
a955c3968b
12 changed files with 138 additions and 1 deletions
5
content/authors/LupinityLabs.md
Normal file
5
content/authors/LupinityLabs.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
username: LupinityLabs
|
||||||
|
name: 'Lupinity Labs | Freelance Software Dev'
|
||||||
|
avatar: 'https://pbs.twimg.com/profile_images/918075255540928514/a0jLVHar_normal.jpg'
|
||||||
|
---
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
username: ecrmnn
|
username: ecrmnn
|
||||||
|
avatar: 'https://pbs.twimg.com/profile_images/1524726574095998976/eIfzkehc_normal.jpg'
|
||||||
name: 'Daniel Eckermann'
|
name: 'Daniel Eckermann'
|
||||||
avatar: 'https://pbs.twimg.com/profile_images/1433834747411767306/rEA7K8oI_normal.jpg'
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
11
content/threads/weekly-thread-2022-24.md
Normal file
11
content/threads/weekly-thread-2022-24.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
slug: weekly-thread-2022-24
|
||||||
|
title: 'Weekly thread #24 of 2022'
|
||||||
|
tweet_id: '1538579116080762880'
|
||||||
|
author_username: archtechx
|
||||||
|
created_at: 2022-06-19T17:47:01+00:00
|
||||||
|
links: { }
|
||||||
|
---
|
||||||
|
🔥 This week's code tips for Laravel developers
|
||||||
|
|
||||||
|
A weekly thread 🧵
|
||||||
15
content/tips/databases-can-generate-random-uuid-keys.md
Normal file
15
content/tips/databases-can-generate-random-uuid-keys.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
title: 'Databases can generate random UUID keys'
|
||||||
|
tweet_id: '1538579134703497216'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: tobias_petry
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FUuDWADWAAAapY7.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:05+00:00
|
||||||
|
slug: databases-can-generate-random-uuid-keys
|
||||||
|
---
|
||||||
|
⚡️ Database Tip
|
||||||
|
|
||||||
|
Many applications use the table's numeric primary key in the URL: Bots can scrape all data by incrementing the ID and competitors know your number of customers/resources and growth.Adding a random UUID which is used in URLs solves this.
|
||||||
|
|
||||||
|
https://sqlfordevs.io/uuid-prevent-enumeration-attack
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: 'Long classes can be split into small single-use traits'
|
||||||
|
tweet_id: '1538579137463406592'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: archtechx
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FVSanUMUcAA5iRg.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:06+00:00
|
||||||
|
slug: long-classes-can-be-split-into-small-single-use-traits
|
||||||
|
---
|
||||||
|
💡 Create single-use traits to split up long classes into smaller parts
|
||||||
|
|
||||||
|
This way, all e.g. link-related logic can be contained within a single trait
|
||||||
13
content/tips/method-parameters-can-be-marked-as-sensitive.md
Normal file
13
content/tips/method-parameters-can-be-marked-as-sensitive.md
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: 'Method parameters can be marked as "sensitive”'
|
||||||
|
tweet_id: '1538579129276059648'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: SteveTheBauman
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FVZSWpkXwAITTAp.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:04+00:00
|
||||||
|
slug: method-parameters-can-be-marked-as-sensitive
|
||||||
|
---
|
||||||
|
Apparently in PHP 8.2, you can mark method parameters as "sensitive" so that they are not printed in debug_backtrace 🤯
|
||||||
|
|
||||||
|
https://php.watch/versions/8.2/backtrace-parameter-redaction
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
title: 'Uploaded files can be attached to emails directly from the request'
|
||||||
|
tweet_id: '1538579118551248896'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: ecrmnn
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FVOf_L_UcAUYEaK.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:01+00:00
|
||||||
|
slug: 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.
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: 'You can add a URI fragment when redirecting to a route'
|
||||||
|
tweet_id: '1538579123949346816'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: ecrmnn
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FVYsVf5VsAEan8N.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:03+00:00
|
||||||
|
slug: 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 📈
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
title: 'You can customize default validation rules for passwords'
|
||||||
|
tweet_id: '1538579140147699712'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: ecrmnn
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FUqvZeiVEAAsdBC.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:07+00:00
|
||||||
|
slug: 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.
|
||||||
13
content/tips/you-can-import-entire-namespaces-in-php.md
Normal file
13
content/tips/you-can-import-entire-namespaces-in-php.md
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: 'You can import entire namespaces in PHP'
|
||||||
|
tweet_id: '1538579126595899393'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: archtechx
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FVYDILtUAAAmQlc.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:03+00:00
|
||||||
|
slug: 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
|
||||||
11
content/tips/you-can-namespace-your-helper-functions.md
Normal file
11
content/tips/you-can-namespace-your-helper-functions.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
title: 'You can namespace your helper functions'
|
||||||
|
tweet_id: '1538579132019187712'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: archtechx
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FUzJCu8UcAAdBfT.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:05+00:00
|
||||||
|
slug: 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
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: 'You can use Eloquent `whereColumn()` to compare columns to each other'
|
||||||
|
tweet_id: '1538579121193701377'
|
||||||
|
thread_slug: weekly-thread-2022-24
|
||||||
|
author_username: LupinityLabs
|
||||||
|
images:
|
||||||
|
- 'https://pbs.twimg.com/media/FUw13BSXEAI1_xQ.jpg'
|
||||||
|
created_at: 2022-06-19T17:47:02+00:00
|
||||||
|
slug: you-can-use-eloquent-wherecolumn-to-compare-columns-to-each-other
|
||||||
|
---
|
||||||
|
💡🟰 Quick #Laravel Eloquent tip for comparing database columns to each other within a query.
|
||||||
|
|
||||||
|
You don't have to use any raw statements to do this - whereColumn() has got you covered! 😊
|
||||||
Loading…
Add table
Add a link
Reference in a new issue