mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
2021-01 to 2022-01
This commit is contained in:
parent
54106ee7d8
commit
f17995357c
14 changed files with 29 additions and 29 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Compare models using is() instead of directly comparing attributes'
|
title: 'Compare models using is() instead of directly comparing attributes'
|
||||||
tweet_id: '1479467936700010504'
|
tweet_id: '1479467936700010504'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: archtechx
|
author_username: archtechx
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHJNmt3VEAIYtCy.jpg'
|
- 'https://pbs.twimg.com/media/FHJNmt3VEAIYtCy.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: compare-models-using-is-instead-of-directly-comparing-attributes
|
||||||
---
|
---
|
||||||
🔥 Tip: Compare models using ->is() instead of doing direct attribute value comparisons
|
🔥 Tip: Compare models using ->is() instead of doing direct attribute value comparisons
|
||||||
|
|
||||||
This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219
|
This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Custom collections pair well with higher order proxies'
|
title: 'Custom collections pair well with higher order proxies'
|
||||||
tweet_id: '1479467951753285637'
|
tweet_id: '1479467951753285637'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: archtechx
|
author_username: archtechx
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIa84E5VUAAQsL1.jpg'
|
- 'https://pbs.twimg.com/media/FIa84E5VUAAQsL1.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: custom-collections-pair-well-with-higher-order-proxies
|
||||||
---
|
---
|
||||||
🔥 Custom collections pair very well with higher order proxies
|
🔥 Custom collections pair very well with higher order proxies
|
||||||
|
|
||||||
When you have some repetitive low level logic that you'd like to abstract into more readable methods that follow your business terminology, custom collections can be a great choice
|
When you have some repetitive low level logic that you'd like to abstract into more readable methods that follow your business terminology, custom collections can be a great choice
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'From PHP 7.4, you can use the spread syntax to merge arrays'
|
title: 'From PHP 7.4, you can use the spread syntax to merge arrays'
|
||||||
tweet_id: '1479467945822588931'
|
tweet_id: '1479467945822588931'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: bhaidar
|
author_username: bhaidar
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIDdCQvVEAMsK3l.jpg'
|
- 'https://pbs.twimg.com/media/FIDdCQvVEAMsK3l.jpg'
|
||||||
|
|
@ -12,4 +12,4 @@ slug: from-php-74-you-can-use-the-spread-syntax-to-merge-arrays
|
||||||
|
|
||||||
Available since PHP 7.4+
|
Available since PHP 7.4+
|
||||||
|
|
||||||
#Laravel
|
#Laravel
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
title: 'Number markdown lists with `1.` rather than the actual number'
|
title: 'Number markdown lists with `1.` rather than the actual number'
|
||||||
tweet_id: '1479467929888440329'
|
tweet_id: '1479467929888440329'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: frankdejonge
|
author_username: frankdejonge
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png'
|
- 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png'
|
||||||
created_at: 2022-01-07T15:00:16+00:00
|
created_at: 2022-01-07T15:00:16+00:00
|
||||||
slug: number-markdown-lists-with-1-rather-than-the-actual-number
|
slug: number-markdown-lists-with-1-rather-than-the-actual-number
|
||||||
---
|
---
|
||||||
💡 A little thing I always like to do. Use only "1." for numbered lists in markdown. The list is rendered the same, but adding an item doesn't require you to renumber the other items 🤘
|
💡 A little thing I always like to do. Use only "1." for numbered lists in markdown. The list is rendered the same, but adding an item doesn't require you to renumber the other items 🤘
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'PHP 8.1 enums can be used as model casts'
|
title: 'PHP 8.1 enums can be used as model casts'
|
||||||
tweet_id: '1479467948985126913'
|
tweet_id: '1479467948985126913'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: ryangjchandler
|
author_username: ryangjchandler
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIRla1cX0AUpxGS.jpg'
|
- 'https://pbs.twimg.com/media/FIRla1cX0AUpxGS.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: php-81-enums-can-be-used-as-model-casts
|
||||||
---
|
---
|
||||||
🔥 Did you know that @laravelphp can cast model columns into instances an enum in PHP 8.1?
|
🔥 Did you know that @laravelphp can cast model columns into instances an enum in PHP 8.1?
|
||||||
|
|
||||||
The example below will create an instance of `OrderStatus` based on variant value. If the `status` column has the value `shipped`, it will return the `OrderStatus::Shipped` variant.
|
The example below will create an instance of `OrderStatus` based on variant value. If the `status` column has the value `shipped`, it will return the `OrderStatus::Shipped` variant.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Use `composer why-not` to see why a dependency cannot be installed'
|
title: 'Use `composer why-not` to see why a dependency cannot be installed'
|
||||||
tweet_id: '1479467931159334915'
|
tweet_id: '1479467931159334915'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: freekmurze
|
author_username: freekmurze
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHFSeQyXMAk3JFi.jpg'
|
- 'https://pbs.twimg.com/media/FHFSeQyXMAk3JFi.jpg'
|
||||||
|
|
@ -9,4 +9,4 @@ created_at: 2022-01-07T15:00:16+00:00
|
||||||
slug: use-composer-why-not-to-see-why-a-dependency-cannot-be-installed
|
slug: use-composer-why-not-to-see-why-a-dependency-cannot-be-installed
|
||||||
---
|
---
|
||||||
🔥 Composer has a `why-not` command that will tell you why it won’t install a particular version of a package
|
🔥 Composer has a `why-not` command that will tell you why it won’t install a particular version of a package
|
||||||
#php
|
#php
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Use partitions for deleting mass amounts of data'
|
title: 'Use partitions for deleting mass amounts of data'
|
||||||
tweet_id: '1479467943276670979'
|
tweet_id: '1479467943276670979'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: tobias_petry
|
author_username: tobias_petry
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg'
|
- 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: use-partitions-for-deleting-mass-amounts-of-data
|
||||||
---
|
---
|
||||||
⚡ ️Database Tip
|
⚡ ️Database Tip
|
||||||
|
|
||||||
Some applications want to periodically deleted old historic data (or have to because of regulations). Deleting billions of rows is a very slow task which could take several minutes and may take your application down. Use partitions for efficient deleting!
|
Some applications want to periodically deleted old historic data (or have to because of regulations). Deleting billions of rows is a very slow task which could take several minutes and may take your application down. Use partitions for efficient deleting!
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Use skip() when writing tests ahead of time'
|
title: 'Use skip() when writing tests ahead of time'
|
||||||
tweet_id: '1479467933705195521'
|
tweet_id: '1479467933705195521'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: bhaidar
|
author_username: bhaidar
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHNHgg4VgAAFSzE.jpg'
|
- 'https://pbs.twimg.com/media/FHNHgg4VgAAFSzE.jpg'
|
||||||
|
|
@ -12,4 +12,4 @@ slug: use-skip-when-writing-tests-ahead-of-time
|
||||||
|
|
||||||
If you like to plan your tests ahead of time and implement them one by one, you can always make use of a handy method `skip()` to tell the test runner to ignore those empty tests.
|
If you like to plan your tests ahead of time and implement them one by one, you can always make use of a handy method `skip()` to tell the test runner to ignore those empty tests.
|
||||||
|
|
||||||
`skip()` accepts a callback too!
|
`skip()` accepts a callback too!
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed'
|
title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed'
|
||||||
tweet_id: '1479467947634556930'
|
tweet_id: '1479467947634556930'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: justsanjit
|
author_username: justsanjit
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHuueNxWUAMLdAP.jpg'
|
- 'https://pbs.twimg.com/media/FHuueNxWUAMLdAP.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rat
|
||||||
---
|
---
|
||||||
🔥 In #mysql you can compare strings by how they sound rather than how they have been typed using SOUNDEX() function
|
🔥 In #mysql you can compare strings by how they sound rather than how they have been typed using SOUNDEX() function
|
||||||
|
|
||||||
#laravelframework #laravel #mysql #sql
|
#laravelframework #laravel #mysql #sql
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'You can supply default values for route parameters'
|
title: 'You can supply default values for route parameters'
|
||||||
tweet_id: '1479467942039285762'
|
tweet_id: '1479467942039285762'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: ryangjchandler
|
author_username: ryangjchandler
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIWa8DxXMAIW7Tz.jpg'
|
- 'https://pbs.twimg.com/media/FIWa8DxXMAIW7Tz.jpg'
|
||||||
|
|
@ -10,4 +10,4 @@ slug: you-can-supply-default-values-for-route-parameters
|
||||||
---
|
---
|
||||||
🔥 Did you know that you can supply default values for route parameters in @laravelphp?
|
🔥 Did you know that you can supply default values for route parameters in @laravelphp?
|
||||||
|
|
||||||
In the screenshot below, we use the current user's account as the default value for `{account}`. This means we don't have to provide it when generating the `users.index` route.
|
In the screenshot below, we use the current user's account as the default value for `{account}`. This means we don't have to provide it when generating the `users.index` route.
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation'
|
title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation'
|
||||||
tweet_id: '1479467939191345152'
|
tweet_id: '1479467939191345152'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: Philo01
|
author_username: Philo01
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg'
|
- 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg'
|
||||||
created_at: 2022-01-07T15:00:18+00:00
|
created_at: 2022-01-07T15:00:18+00:00
|
||||||
slug: you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation
|
slug: you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation
|
||||||
---
|
---
|
||||||
Laravel Tip 💡 You can use the 'Blade::stringable' method to convert objects into their string representation. For example, automatically convert a Money object and show the amount in a specific currency.
|
Laravel Tip 💡 You can use the 'Blade::stringable' method to convert objects into their string representation. For example, automatically convert a Money object and show the amount in a specific currency.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'You can use first class callables for routes in PHP 8.1'
|
title: 'You can use first class callables for routes in PHP 8.1'
|
||||||
tweet_id: '1479467932379799552'
|
tweet_id: '1479467932379799552'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: archtechx
|
author_username: archtechx
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FHNP2kIVUAIqiCH.jpg'
|
- 'https://pbs.twimg.com/media/FHNP2kIVUAIqiCH.jpg'
|
||||||
|
|
@ -12,4 +12,4 @@ slug: you-can-use-first-class-callables-for-routes-in-php-81
|
||||||
|
|
||||||
The caveat is that the methods need to be static because there's no syntax for referencing instance methods on classes
|
The caveat is that the methods need to be static because there's no syntax for referencing instance methods on classes
|
||||||
|
|
||||||
I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard
|
I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned'
|
title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned'
|
||||||
tweet_id: '1479467944581033986'
|
tweet_id: '1479467944581033986'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: freekmurze
|
author_username: freekmurze
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIN1v4NWUAARbol.jpg'
|
- 'https://pbs.twimg.com/media/FIN1v4NWUAARbol.jpg'
|
||||||
|
|
@ -12,6 +12,6 @@ This is how you can hint that a function returns an instance of the class of whi
|
||||||
|
|
||||||
Cool stuff!
|
Cool stuff!
|
||||||
|
|
||||||
Hat tip to @enunomaduro
|
Hat tip to @enunomaduro
|
||||||
|
|
||||||
https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107
|
https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 'You can use `onerror` on the image tag'
|
title: 'You can use `onerror` on the image tag'
|
||||||
tweet_id: '1479467940726468609'
|
tweet_id: '1479467940726468609'
|
||||||
thread_slug: weekly-thread-2021-01
|
thread_slug: weekly-thread-2022-01
|
||||||
author_username: JuanDMeGon
|
author_username: JuanDMeGon
|
||||||
images:
|
images:
|
||||||
- 'https://pbs.twimg.com/media/FIWjvXSWUAYjM-j.jpg'
|
- 'https://pbs.twimg.com/media/FIWjvXSWUAYjM-j.jpg'
|
||||||
|
|
@ -9,4 +9,4 @@ created_at: 2022-01-07T15:00:18+00:00
|
||||||
slug: you-can-use-onerror-on-the-image-tag
|
slug: you-can-use-onerror-on-the-image-tag
|
||||||
---
|
---
|
||||||
😲 TIL:
|
😲 TIL:
|
||||||
You can hide an image when it is broken so you don't get that ugly broken image icon from the browser.
|
You can hide an image when it is broken so you don't get that ugly broken image icon from the browser.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue