1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-11 21:14:02 +00:00
This commit is contained in:
Samuel Štancl 2022-04-09 02:35:20 +02:00
parent 876878c43a
commit a2adc750ad
13 changed files with 131 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
username: BurtDS
name: 'Bert De Swaef'
avatar: 'https://pbs.twimg.com/profile_images/1042044375688196097/Ktoa7v3p_normal.jpg'
---

View file

@ -0,0 +1,5 @@
---
username: joemasilotti
name: 'Joe Masilotti 📗'
avatar: 'https://pbs.twimg.com/profile_images/1469703667791982596/5-0pGyNV_normal.jpg'
---

View file

@ -1,5 +1,5 @@
---
username: ryangjchandler
avatar: 'https://pbs.twimg.com/profile_images/1507600871370391557/Em6_vfLo_normal.png'
avatar: 'https://pbs.twimg.com/profile_images/1512466908746235904/6jQdQZim_normal.png'
name: 'Ryan Chandler'
---

View file

@ -0,0 +1,5 @@
---
username: victoryoalli
name: '🧔🏻Victor Yoalli'
avatar: 'https://pbs.twimg.com/profile_images/1511729912297627657/LmidlmsF_normal.png'
---

View file

@ -0,0 +1,11 @@
---
slug: weekly-thread-2022-14
title: 'Weekly thread #14 of 2022'
tweet_id: '1512463786405294081'
author_username: archtechx
created_at: 2022-04-08T16:14:01+00:00
links: { }
---
🔥 This week's code tips for Laravel developers
A weekly thread 🧵

View file

@ -0,0 +1,13 @@
---
title: 'You can associate an input with a form using the form= attribute'
tweet_id: '1512463810069598212'
thread_slug: weekly-thread-2022-14
author_username: joemasilotti
images:
- 'https://pbs.twimg.com/media/FPh2K65VQAQO5xz.jpg'
created_at: 2022-04-08T16:14:07+00:00
slug: you-can-associate-an-input-with-a-form-using-the-form-attribute
---
Wait... what?! 🤯
https://www.smashingmagazine.com/2022/03/html-attributes-you-never-use/#the-form-attribute-for-form-fields

View file

@ -0,0 +1,13 @@
---
title: 'You can calculate the `age()` of Carbon instances'
tweet_id: '1512463795364384771'
thread_slug: weekly-thread-2022-14
author_username: victoryoalli
images:
- 'https://pbs.twimg.com/media/FPh7dVyWUAEW5EQ.jpg'
created_at: 2022-04-08T16:14:03+00:00
slug: you-can-calculate-the-age-of-carbon-instances
---
#TIL How to calculate the age using a date in Laravel or using Carbon.
#LaravelTip #PHPTip #dev

View file

@ -0,0 +1,11 @@
---
title: 'You can call `squish()` on Stringable instances to remove all unnecessary whitespaces'
tweet_id: '1512463789215477763'
thread_slug: weekly-thread-2022-14
author_username: mattkingshott
images:
- 'https://pbs.twimg.com/media/FPqzjjnWUAAolDJ.jpg'
created_at: 2022-04-08T16:14:02+00:00
slug: you-can-call-squish-on-stringable-instances-to-remove-all-unnecessary-whitespaces
---
🔥 #Laravel Tip: Hot off the press, the latest release includes the squish global helper method by @DwightConrad. It removes all extraneous white space from a string, including between words. Its like trim on steroids :)

View file

@ -0,0 +1,14 @@
---
title: 'You can call `withTrashed()` on a route to accept soft deleted models'
tweet_id: '1512463792432566274'
thread_slug: weekly-thread-2022-14
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FPizAZxVsAUl-WZ.jpg'
created_at: 2022-04-08T16:14:02+00:00
slug: you-can-call-withtrashed-on-a-route-to-accept-soft-deleted-models
---
🔥 Laravel Tip: Route model binding soft-deleted models
By default, when using route model binding will not retrieve models that have been soft-deleted.
You can change that behavior by using `withTrashed` in your route.

View file

@ -0,0 +1,15 @@
---
title: 'You can create DB indices for transformed versions of columns'
tweet_id: '1512463807167139846'
thread_slug: weekly-thread-2022-14
author_username: tobias_petry
images:
- 'https://pbs.twimg.com/media/FPk6CjSWYAAXwyn.jpg'
created_at: 2022-04-08T16:14:06+00:00
slug: you-can-create-db-indices-for-transformed-versions-of-columns
---
⚡️ 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.io/tips/function-based-index?utm_source=twitter&utm_medium=social&utm_campaign=database_tip_2022_04_05

View file

@ -0,0 +1,11 @@
---
title: 'You can create Storage disks on the fly'
tweet_id: '1512463804205973508'
thread_slug: weekly-thread-2022-14
author_username: ryangjchandler
images:
- 'https://pbs.twimg.com/media/FPwqSygWYAAbSUh.jpg'
created_at: 2022-04-08T16:14:05+00:00
slug: you-can-create-storage-disks-on-the-fly
---
🔥 Did you know that you can create Storage disks on the fly in @laravelphp? This is super useful when you want your user to provide their own filesystem credentials, e.g. a user can bring their own S3 bucket to your app.

View file

@ -0,0 +1,14 @@
---
title: 'You can temporarily disable timestamps when saving a model'
tweet_id: '1512463801278291971'
thread_slug: weekly-thread-2022-14
author_username: BurtDS
images:
- 'https://pbs.twimg.com/media/FPe3PztWQAIaXzC.jpg'
created_at: 2022-04-08T16:14:05+00:00
slug: you-can-temporarily-disable-timestamps-when-saving-a-model
---
📝 #Laravel Tip | In some cases you don't want the updated_at field the change when updating small things. .. Did you know you could disable the timestamps while saving your data?
Here is how... 🔥
#laraveltip #php #code #development #details

View file

@ -0,0 +1,13 @@
---
title: 'You can use the `missing` method to customize 404 handling on a route'
tweet_id: '1512463798287814658'
thread_slug: weekly-thread-2022-14
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FPi0WYWUYAQXuWf.jpg'
created_at: 2022-04-08T16:14:04+00:00
slug: you-can-use-the-missing-method-to-customize-404-handling-on-a-route
---
🔥 Laravel tip: Customizing Missing Model Behavior in route model bindings
By default, Laravel throws a 404 error when it can't bind the model, but you can change that behavior by passing a closure to the missing method.