From 179261fceb25cd56593b2cfef067b9643181f6d7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 7 Jan 2022 17:38:01 +0100 Subject: [PATCH 1/6] Weekly thread #51 --- content/authors/bhaidar.md | 5 +++++ content/authors/frankdejonge.md | 5 +++++ content/authors/justsanjit.md | 5 +++++ content/authors/ryangjchandler.md | 5 +++++ content/threads/weekly-thread-2021-01.md | 8 ++++---- ...-instead-of-directly-comparing-attributes.md | 13 +++++++++++++ ...tions-pair-well-with-higher-order-proxies.md | 13 +++++++++++++ ...can-use-the-spread-syntax-to-merge-arrays.md | 15 +++++++++++++++ ...ists-with-1-rather-than-the-actual-number.md | 11 +++++++++++ .../php-81-enums-can-be-used-as-model-casts.md | 13 +++++++++++++ ...-see-why-a-dependency-cannot-be-installed.md | 12 ++++++++++++ ...titions-for-deleting-mass-amounts-of-data.md | 13 +++++++++++++ ...use-skip-when-writing-tests-ahead-of-time.md | 15 +++++++++++++++ ...w-they-sound-rather-than-how-theyre-typed.md | 13 +++++++++++++ ...upply-default-values-for-route-parameters.md | 13 +++++++++++++ ...-converted-to-their-string-representation.md | 11 +++++++++++ ...irst-class-callables-for-routes-in-php-81.md | 15 +++++++++++++++ ...-instance-of-the-passed-class-is-returned.md | 17 +++++++++++++++++ .../you-can-use-onerror-on-the-image-tag.md | 12 ++++++++++++ 19 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 content/authors/bhaidar.md create mode 100644 content/authors/frankdejonge.md create mode 100644 content/authors/justsanjit.md create mode 100644 content/authors/ryangjchandler.md create mode 100644 content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md create mode 100644 content/tips/custom-collections-pair-well-with-higher-order-proxies.md create mode 100644 content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md create mode 100644 content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md create mode 100644 content/tips/php-81-enums-can-be-used-as-model-casts.md create mode 100644 content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md create mode 100644 content/tips/use-partitions-for-deleting-mass-amounts-of-data.md create mode 100644 content/tips/use-skip-when-writing-tests-ahead-of-time.md create mode 100644 content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md create mode 100644 content/tips/you-can-supply-default-values-for-route-parameters.md create mode 100644 content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md create mode 100644 content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md create mode 100644 content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md create mode 100644 content/tips/you-can-use-onerror-on-the-image-tag.md diff --git a/content/authors/bhaidar.md b/content/authors/bhaidar.md new file mode 100644 index 0000000..5428751 --- /dev/null +++ b/content/authors/bhaidar.md @@ -0,0 +1,5 @@ +--- +username: bhaidar +name: 'Bilal Haidar' +avatar: 'https://pbs.twimg.com/profile_images/1381347341400215552/LvVOFV9__normal.jpg' +--- diff --git a/content/authors/frankdejonge.md b/content/authors/frankdejonge.md new file mode 100644 index 0000000..f7ab9b0 --- /dev/null +++ b/content/authors/frankdejonge.md @@ -0,0 +1,5 @@ +--- +username: frankdejonge +name: 'Frank de Jonge' +avatar: 'https://pbs.twimg.com/profile_images/1458371876426821636/MFOPqVaX_normal.jpg' +--- diff --git a/content/authors/justsanjit.md b/content/authors/justsanjit.md new file mode 100644 index 0000000..757928a --- /dev/null +++ b/content/authors/justsanjit.md @@ -0,0 +1,5 @@ +--- +username: justsanjit +name: 'Sanjit Singh' +avatar: 'https://pbs.twimg.com/profile_images/1478587890078683142/sefIvjbF_normal.jpg' +--- diff --git a/content/authors/ryangjchandler.md b/content/authors/ryangjchandler.md new file mode 100644 index 0000000..70a0730 --- /dev/null +++ b/content/authors/ryangjchandler.md @@ -0,0 +1,5 @@ +--- +username: ryangjchandler +name: 'Ryan Chandler' +avatar: 'https://pbs.twimg.com/profile_images/1446231529986961410/X5zL_n0h_normal.jpg' +--- diff --git a/content/threads/weekly-thread-2021-01.md b/content/threads/weekly-thread-2021-01.md index 650db90..6888556 100644 --- a/content/threads/weekly-thread-2021-01.md +++ b/content/threads/weekly-thread-2021-01.md @@ -1,11 +1,11 @@ --- slug: weekly-thread-2021-01 title: 'Weekly thread #01 of 2021' -tweet_id: '1471864631312404492' +tweet_id: '1479467928818892800' author_username: archtechx -created_at: 2022-01-07T12:56:47+00:00 +created_at: 2022-01-07T16:35:34+00:00 links: { } --- -🔥 This week's code tips for Laravel developers +🔥 Latest code tips for Laravel developers -A weekly thread 🧵 \ No newline at end of file +First week's special: news from the past 3 weeks 🧵 \ No newline at end of file diff --git a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md new file mode 100644 index 0000000..71931e4 --- /dev/null +++ b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md @@ -0,0 +1,13 @@ +--- +title: 'Compare models using is() instead of directly comparing attributes' +tweet_id: '1479467936700010504' +thread_slug: weekly-thread-2021-01 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FHJNmt3VEAIYtCy.jpg' +created_at: 2022-01-07T15:00:17+00:00 +slug: compare-models-using-is-instead-of-directly-comparing-attributes +--- +🔥 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 \ No newline at end of file diff --git a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md new file mode 100644 index 0000000..47711bd --- /dev/null +++ b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md @@ -0,0 +1,13 @@ +--- +title: 'Custom collections pair well with higher order proxies' +tweet_id: '1479467951753285637' +thread_slug: weekly-thread-2021-01 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FIa84E5VUAAQsL1.jpg' +created_at: 2022-01-07T15:00:21+00:00 +slug: custom-collections-pair-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 \ No newline at end of file diff --git a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md new file mode 100644 index 0000000..8b50ce5 --- /dev/null +++ b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md @@ -0,0 +1,15 @@ +--- +title: 'From PHP 7.4, you can use the spread syntax to merge arrays' +tweet_id: '1479467945822588931' +thread_slug: weekly-thread-2021-01 +author_username: bhaidar +images: + - 'https://pbs.twimg.com/media/FIDdCQvVEAMsK3l.jpg' +created_at: 2022-01-07T15:00:20+00:00 +slug: from-php-74-you-can-use-the-spread-syntax-to-merge-arrays +--- +🌶️ #PHP tip: Did you know that you can use the spread operator to merge arrays, just like you do it in #javascript? + +Available since PHP 7.4+ + +#Laravel \ No newline at end of file diff --git a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md new file mode 100644 index 0000000..335c00d --- /dev/null +++ b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md @@ -0,0 +1,11 @@ +--- +title: 'Number markdown lists with `1.` rather than the actual number' +tweet_id: '1479467929888440329' +thread_slug: weekly-thread-2021-01 +author_username: frankdejonge +images: + - 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png' +created_at: 2022-01-07T15:00:16+00:00 +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 🤘 \ No newline at end of file diff --git a/content/tips/php-81-enums-can-be-used-as-model-casts.md b/content/tips/php-81-enums-can-be-used-as-model-casts.md new file mode 100644 index 0000000..14000e8 --- /dev/null +++ b/content/tips/php-81-enums-can-be-used-as-model-casts.md @@ -0,0 +1,13 @@ +--- +title: 'PHP 8.1 enums can be used as model casts' +tweet_id: '1479467948985126913' +thread_slug: weekly-thread-2021-01 +author_username: ryangjchandler +images: + - 'https://pbs.twimg.com/media/FIRla1cX0AUpxGS.jpg' +created_at: 2022-01-07T15:00:20+00:00 +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? + +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. \ No newline at end of file diff --git a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md new file mode 100644 index 0000000..2413ebe --- /dev/null +++ b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md @@ -0,0 +1,12 @@ +--- +title: 'Use `composer why-not` to see why a dependency cannot be installed' +tweet_id: '1479467931159334915' +thread_slug: weekly-thread-2021-01 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FHFSeQyXMAk3JFi.jpg' +created_at: 2022-01-07T15:00:16+00:00 +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 +#php \ No newline at end of file diff --git a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md new file mode 100644 index 0000000..4ebf82b --- /dev/null +++ b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md @@ -0,0 +1,13 @@ +--- +title: 'Use partitions for deleting mass amounts of data' +tweet_id: '1479467943276670979' +thread_slug: weekly-thread-2021-01 +author_username: tobias_petry +images: + - 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg' +created_at: 2022-01-07T15:00:19+00:00 +slug: use-partitions-for-deleting-mass-amounts-of-data +--- +⚡ ️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! \ No newline at end of file diff --git a/content/tips/use-skip-when-writing-tests-ahead-of-time.md b/content/tips/use-skip-when-writing-tests-ahead-of-time.md new file mode 100644 index 0000000..f7270d5 --- /dev/null +++ b/content/tips/use-skip-when-writing-tests-ahead-of-time.md @@ -0,0 +1,15 @@ +--- +title: 'Use skip() when writing tests ahead of time' +tweet_id: '1479467933705195521' +thread_slug: weekly-thread-2021-01 +author_username: bhaidar +images: + - 'https://pbs.twimg.com/media/FHNHgg4VgAAFSzE.jpg' +created_at: 2022-01-07T15:00:17+00:00 +slug: use-skip-when-writing-tests-ahead-of-time +--- +🌶️ #Laravel #pestphp tip + +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! \ No newline at end of file diff --git a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md new file mode 100644 index 0000000..0e717bc --- /dev/null +++ b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md @@ -0,0 +1,13 @@ +--- +title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed' +tweet_id: '1479467947634556930' +thread_slug: weekly-thread-2021-01 +author_username: justsanjit +images: + - 'https://pbs.twimg.com/media/FHuueNxWUAMLdAP.jpg' +created_at: 2022-01-07T15:00:20+00:00 +slug: use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed +--- +🔥 In #mysql you can compare strings by how they sound rather than how they have been typed using SOUNDEX() function + +#laravelframework #laravel #mysql #sql \ No newline at end of file diff --git a/content/tips/you-can-supply-default-values-for-route-parameters.md b/content/tips/you-can-supply-default-values-for-route-parameters.md new file mode 100644 index 0000000..36e98bc --- /dev/null +++ b/content/tips/you-can-supply-default-values-for-route-parameters.md @@ -0,0 +1,13 @@ +--- +title: 'You can supply default values for route parameters' +tweet_id: '1479467942039285762' +thread_slug: weekly-thread-2021-01 +author_username: ryangjchandler +images: + - 'https://pbs.twimg.com/media/FIWa8DxXMAIW7Tz.jpg' +created_at: 2022-01-07T15:00:19+00:00 +slug: you-can-supply-default-values-for-route-parameters +--- +🔥 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. \ No newline at end of file diff --git a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md new file mode 100644 index 0000000..9d921da --- /dev/null +++ b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md @@ -0,0 +1,11 @@ +--- +title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation' +tweet_id: '1479467939191345152' +thread_slug: weekly-thread-2021-01 +author_username: Philo01 +images: + - 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg' +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 +--- +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. \ No newline at end of file diff --git a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md new file mode 100644 index 0000000..94be80f --- /dev/null +++ b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md @@ -0,0 +1,15 @@ +--- +title: 'You can use first class callables for routes in PHP 8.1' +tweet_id: '1479467932379799552' +thread_slug: weekly-thread-2021-01 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FHNP2kIVUAIqiCH.jpg' +created_at: 2022-01-07T15:00:16+00:00 +slug: you-can-use-first-class-callables-for-routes-in-php-81 +--- +🔥 You can use first class callables for routes in PHP 8.1 + +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 \ No newline at end of file diff --git a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md new file mode 100644 index 0000000..f0393fc --- /dev/null +++ b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md @@ -0,0 +1,17 @@ +--- +title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned' +tweet_id: '1479467944581033986' +thread_slug: weekly-thread-2021-01 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FIN1v4NWUAARbol.jpg' +created_at: 2022-01-07T15:00:19+00:00 +slug: you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned +--- +This is how you can hint that a function returns an instance of the class of which you passed the class name. + +Cool stuff! + +Hat tip to @enunomaduro + +https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107 \ No newline at end of file diff --git a/content/tips/you-can-use-onerror-on-the-image-tag.md b/content/tips/you-can-use-onerror-on-the-image-tag.md new file mode 100644 index 0000000..8cfca5f --- /dev/null +++ b/content/tips/you-can-use-onerror-on-the-image-tag.md @@ -0,0 +1,12 @@ +--- +title: 'You can use `onerror` on the image tag' +tweet_id: '1479467940726468609' +thread_slug: weekly-thread-2021-01 +author_username: JuanDMeGon +images: + - 'https://pbs.twimg.com/media/FIWjvXSWUAYjM-j.jpg' +created_at: 2022-01-07T15:00:18+00:00 +slug: you-can-use-onerror-on-the-image-tag +--- +😲 TIL: +You can hide an image when it is broken so you don't get that ugly broken image icon from the browser. \ No newline at end of file From 1fb4afb503121a4b36fd6c17a64f972b46f4701b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 7 Jan 2022 17:45:22 +0100 Subject: [PATCH 2/6] 2022 --- app/Console/Commands/WeeklyThread.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/WeeklyThread.php b/app/Console/Commands/WeeklyThread.php index f02b7c2..fe1214b 100644 --- a/app/Console/Commands/WeeklyThread.php +++ b/app/Console/Commands/WeeklyThread.php @@ -25,7 +25,7 @@ class WeeklyThread extends Command // 1448992205138444334 $id = $this->extractID($url); - $slug = 'weekly-thread-2021-' . $week; + $slug = 'weekly-thread-2022-' . $week; Tip::where('thread_slug', $slug)->delete(); Thread::where('slug', $slug)->delete(); @@ -35,7 +35,7 @@ class WeeklyThread extends Command /** @var Thread $thread */ $thread = Thread::create([ 'slug' => $slug, - 'title' => "Weekly thread #{$week} of 2021", + 'title' => "Weekly thread #{$week} of 2022", 'tweet_id' => $id, 'author_username' => 'archtechx', 'content' => $tweet->text, From d1baa50b87a9475983e10cdee57df22ed3330464 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 7 Jan 2022 17:46:41 +0100 Subject: [PATCH 3/6] Update content/threads/weekly-thread-2022-01.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Samuel Štancl --- content/threads/weekly-thread-2021-01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/threads/weekly-thread-2021-01.md b/content/threads/weekly-thread-2021-01.md index 6888556..a44bc77 100644 --- a/content/threads/weekly-thread-2021-01.md +++ b/content/threads/weekly-thread-2021-01.md @@ -1,6 +1,6 @@ --- slug: weekly-thread-2021-01 -title: 'Weekly thread #01 of 2021' +title: 'Weekly thread #01 of 2022' tweet_id: '1479467928818892800' author_username: archtechx created_at: 2022-01-07T16:35:34+00:00 From 3f8062e7134161efd2f3ee1731cde12b3bfa76f7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 7 Jan 2022 17:49:46 +0100 Subject: [PATCH 4/6] Change 2021-01 to 2022-01 --- .../{weekly-thread-2021-01.md => weekly-thread-2022-01.md} | 4 ++-- ...ther-column-is-a-great-way-to-speed-up-db-performance.md | 4 ++-- ...els-using-is-instead-of-directly-comparing-attributes.md | 4 ++-- ...ustom-collections-pair-well-with-higher-order-proxies.md | 4 ++-- ...-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md | 4 ++-- ...r-markdown-lists-with-1-rather-than-the-actual-number.md | 4 ++-- content/tips/php-81-enums-can-be-used-as-model-casts.md | 4 ++-- ...r-why-not-to-see-why-a-dependency-cannot-be-installed.md | 4 ++-- ...atabase-queries-based-on-query-strings-in-the-request.md | 6 +++--- .../use-partitions-for-deleting-mass-amounts-of-data.md | 4 ++-- .../tips/use-retry-for-callbacks-that-may-randomly-fail.md | 4 ++-- content/tips/use-skip-when-writing-tests-ahead-of-time.md | 4 ++-- ...trings-by-how-they-sound-rather-than-how-theyre-typed.md | 4 ++-- ...-down-command-to-send-a-refresh-header-to-the-browser.md | 2 +- ...-lookup-tables-match-statements-and-switch-statements.md | 4 ++-- .../you-can-supply-default-values-for-route-parameters.md | 4 ++-- ...ts-should-be-converted-to-their-string-representation.md | 4 ++-- ...ou-can-use-first-class-callables-for-routes-in-php-81.md | 4 ++-- ...hint-that-an-instance-of-the-passed-class-is-returned.md | 6 +++--- content/tips/you-can-use-onerror-on-the-image-tag.md | 4 ++-- ...tax-to-pass-an-array-of-arguments-to-another-function.md | 4 ++-- 21 files changed, 43 insertions(+), 43 deletions(-) rename content/threads/{weekly-thread-2021-01.md => weekly-thread-2022-01.md} (70%) diff --git a/content/threads/weekly-thread-2021-01.md b/content/threads/weekly-thread-2022-01.md similarity index 70% rename from content/threads/weekly-thread-2021-01.md rename to content/threads/weekly-thread-2022-01.md index a44bc77..0f46fbf 100644 --- a/content/threads/weekly-thread-2021-01.md +++ b/content/threads/weekly-thread-2022-01.md @@ -1,5 +1,5 @@ --- -slug: weekly-thread-2021-01 +slug: weekly-thread-2022-01 title: 'Weekly thread #01 of 2022' tweet_id: '1479467928818892800' author_username: archtechx @@ -8,4 +8,4 @@ links: { } --- 🔥 Latest code tips for Laravel developers -First week's special: news from the past 3 weeks 🧵 \ No newline at end of file +First week's special: news from the past 3 weeks 🧵 diff --git a/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md index 5f6ac5c..517ea33 100644 --- a/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md +++ b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md @@ -1,7 +1,7 @@ --- title: 'Adding WHERE scopes which use an indexed column to a query that''s primarily filtered by another column is a great way to speed up DB performance' tweet_id: '1471864653491974151' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: tobias_petry images: - 'https://pbs.twimg.com/media/FGafd_JXMAEDgP5.jpg' @@ -10,4 +10,4 @@ slug: adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily --- ⚡️ Database Tip -Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition. \ No newline at end of file +Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition. diff --git a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md index 71931e4..e0b4733 100644 --- a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md +++ b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md @@ -1,7 +1,7 @@ --- title: 'Compare models using is() instead of directly comparing attributes' tweet_id: '1479467936700010504' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219 \ No newline at end of file +This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219 diff --git a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md index 47711bd..85d4e8e 100644 --- a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md +++ b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md @@ -1,7 +1,7 @@ --- title: 'Custom collections pair well with higher order proxies' tweet_id: '1479467951753285637' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -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 \ No newline at end of file +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 diff --git a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md index 8b50ce5..63c3c45 100644 --- a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md +++ b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md @@ -1,7 +1,7 @@ --- title: 'From PHP 7.4, you can use the spread syntax to merge arrays' tweet_id: '1479467945822588931' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: bhaidar images: - '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+ -#Laravel \ No newline at end of file +#Laravel diff --git a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md index 335c00d..12a2e32 100644 --- a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md +++ b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md @@ -1,11 +1,11 @@ --- title: 'Number markdown lists with `1.` rather than the actual number' tweet_id: '1479467929888440329' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: frankdejonge images: - 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png' created_at: 2022-01-07T15:00:16+00:00 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 🤘 \ No newline at end of file +💡 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 🤘 diff --git a/content/tips/php-81-enums-can-be-used-as-model-casts.md b/content/tips/php-81-enums-can-be-used-as-model-casts.md index 14000e8..07fb2b1 100644 --- a/content/tips/php-81-enums-can-be-used-as-model-casts.md +++ b/content/tips/php-81-enums-can-be-used-as-model-casts.md @@ -1,7 +1,7 @@ --- title: 'PHP 8.1 enums can be used as model casts' tweet_id: '1479467948985126913' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file +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. diff --git a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md index 2413ebe..74b1cd1 100644 --- a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md +++ b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md @@ -1,7 +1,7 @@ --- title: 'Use `composer why-not` to see why a dependency cannot be installed' tweet_id: '1479467931159334915' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: freekmurze images: - '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 --- 🔥 Composer has a `why-not` command that will tell you why it won’t install a particular version of a package -#php \ No newline at end of file +#php diff --git a/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md index 70c3f7d..ec66634 100644 --- a/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md +++ b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md @@ -1,13 +1,13 @@ --- title: 'Use match () or switch () statements to conditionally scope database queries based on query strings in the request' tweet_id: '1471864655710670854' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - 'https://pbs.twimg.com/media/FGmQH5nXEAs4mnv.jpg' created_at: 2021-12-17T15:27:34+00:00 slug: use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request --- -Remembered this great tip recently, and it's nice to see how fast PHP evolves +Remembered this great tip recently, and it's nice to see how fast PHP evolves -The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback ⚡️ https://twitter.com/reinink/status/1233017064492761088 \ No newline at end of file +The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback ⚡️ https://twitter.com/reinink/status/1233017064492761088 diff --git a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md index 4ebf82b..72f8dd7 100644 --- a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md +++ b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md @@ -1,7 +1,7 @@ --- title: 'Use partitions for deleting mass amounts of data' tweet_id: '1479467943276670979' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: tobias_petry images: - 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg' @@ -10,4 +10,4 @@ slug: use-partitions-for-deleting-mass-amounts-of-data --- ⚡ ️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! \ No newline at end of file +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! diff --git a/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md index ddb53b1..7adedfd 100644 --- a/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md +++ b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md @@ -1,7 +1,7 @@ --- title: 'Use retry() for callbacks that may randomly fail' tweet_id: '1471864638199451648' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: alexjgarrett images: - 'https://pbs.twimg.com/media/FGP3MSQWQAYKjSm.jpg' @@ -12,4 +12,4 @@ slug: use-retry-for-callbacks-that-may-randomly-fail I was hitting a shaky API that sometimes failed. -Here, the retry function tries the callback 3 times, with a 2 second interval in-between retries. \ No newline at end of file +Here, the retry function tries the callback 3 times, with a 2 second interval in-between retries. diff --git a/content/tips/use-skip-when-writing-tests-ahead-of-time.md b/content/tips/use-skip-when-writing-tests-ahead-of-time.md index f7270d5..39b52a7 100644 --- a/content/tips/use-skip-when-writing-tests-ahead-of-time.md +++ b/content/tips/use-skip-when-writing-tests-ahead-of-time.md @@ -1,7 +1,7 @@ --- title: 'Use skip() when writing tests ahead of time' tweet_id: '1479467933705195521' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: bhaidar images: - '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. -`skip()` accepts a callback too! \ No newline at end of file +`skip()` accepts a callback too! diff --git a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md index 0e717bc..13c2cab 100644 --- a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md +++ b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md @@ -1,7 +1,7 @@ --- title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed' tweet_id: '1479467947634556930' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: justsanjit images: - '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 -#laravelframework #laravel #mysql #sql \ No newline at end of file +#laravelframework #laravel #mysql #sql diff --git a/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md index 6f70135..062e3cc 100644 --- a/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md +++ b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md @@ -1,7 +1,7 @@ --- title: 'You can add a --refresh flag to the artisan down command to send a refresh header to the browser' tweet_id: '1471864676652826626' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: DianaWebdev images: - 'https://pbs.twimg.com/media/FG0dHeBXwAw3bvc.jpg' diff --git a/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md index 0bf31f8..d9dd5d2 100644 --- a/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md +++ b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md @@ -1,7 +1,7 @@ --- title: 'You can refactor cluttered if () conditions using lookup tables, match statements, and switch statements' tweet_id: '1471864664661311488' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - 'https://pbs.twimg.com/media/FGVrAKdVgAIWfwk.jpg' @@ -12,4 +12,4 @@ slug: you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-stateme First: lookup tables 👇 -These are great for refactoring complex conditions with lots of else if () cases \ No newline at end of file +These are great for refactoring complex conditions with lots of else if () cases diff --git a/content/tips/you-can-supply-default-values-for-route-parameters.md b/content/tips/you-can-supply-default-values-for-route-parameters.md index 36e98bc..5da5f1a 100644 --- a/content/tips/you-can-supply-default-values-for-route-parameters.md +++ b/content/tips/you-can-supply-default-values-for-route-parameters.md @@ -1,7 +1,7 @@ --- title: 'You can supply default values for route parameters' tweet_id: '1479467942039285762' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file +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. diff --git a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md index 9d921da..24dbb6e 100644 --- a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md +++ b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md @@ -1,11 +1,11 @@ --- title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation' tweet_id: '1479467939191345152' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: Philo01 images: - 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg' 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 --- -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. \ No newline at end of file +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. diff --git a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md index 94be80f..3724fb4 100644 --- a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md +++ b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md @@ -1,7 +1,7 @@ --- title: 'You can use first class callables for routes in PHP 8.1' tweet_id: '1479467932379799552' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard \ No newline at end of file +I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard diff --git a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md index f0393fc..36de745 100644 --- a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md +++ b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md @@ -1,7 +1,7 @@ --- title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned' tweet_id: '1479467944581033986' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: freekmurze images: - '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! -Hat tip to @enunomaduro +Hat tip to @enunomaduro -https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107 \ No newline at end of file +https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107 diff --git a/content/tips/you-can-use-onerror-on-the-image-tag.md b/content/tips/you-can-use-onerror-on-the-image-tag.md index 8cfca5f..7b3e8dd 100644 --- a/content/tips/you-can-use-onerror-on-the-image-tag.md +++ b/content/tips/you-can-use-onerror-on-the-image-tag.md @@ -1,7 +1,7 @@ --- title: 'You can use `onerror` on the image tag' tweet_id: '1479467940726468609' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: JuanDMeGon images: - '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 --- 😲 TIL: -You can hide an image when it is broken so you don't get that ugly broken image icon from the browser. \ No newline at end of file +You can hide an image when it is broken so you don't get that ugly broken image icon from the browser. diff --git a/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md index adbe5df..4356e1e 100644 --- a/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md +++ b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md @@ -1,7 +1,7 @@ --- title: 'You can use the array spread syntax to pass an array of arguments to another function' tweet_id: '1471864644562305025' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: freekmurze images: - 'https://pbs.twimg.com/media/FGepj8mWQAUf2R_.jpg' @@ -14,4 +14,4 @@ Here’s a self-contained example where we spread the array output of sys_getloa https://github.com/spatie/cpu-load-health-check/blob/70f387d5167c24d4000d825a5bddab2504d557fb/src/CpuLoad.php#L17 -#php \ No newline at end of file +#php From a8b4fb8c99bec08003ee8042a61d6be82ef4dce6 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 7 Jan 2022 18:32:23 +0100 Subject: [PATCH 5/6] Revert "Change 2021-01 to 2022-01" This reverts commit 3f8062e7134161efd2f3ee1731cde12b3bfa76f7. --- .../{weekly-thread-2022-01.md => weekly-thread-2021-01.md} | 4 ++-- ...ther-column-is-a-great-way-to-speed-up-db-performance.md | 4 ++-- ...els-using-is-instead-of-directly-comparing-attributes.md | 4 ++-- ...ustom-collections-pair-well-with-higher-order-proxies.md | 4 ++-- ...-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md | 4 ++-- ...r-markdown-lists-with-1-rather-than-the-actual-number.md | 4 ++-- content/tips/php-81-enums-can-be-used-as-model-casts.md | 4 ++-- ...r-why-not-to-see-why-a-dependency-cannot-be-installed.md | 4 ++-- ...atabase-queries-based-on-query-strings-in-the-request.md | 6 +++--- .../use-partitions-for-deleting-mass-amounts-of-data.md | 4 ++-- .../tips/use-retry-for-callbacks-that-may-randomly-fail.md | 4 ++-- content/tips/use-skip-when-writing-tests-ahead-of-time.md | 4 ++-- ...trings-by-how-they-sound-rather-than-how-theyre-typed.md | 4 ++-- ...-down-command-to-send-a-refresh-header-to-the-browser.md | 2 +- ...-lookup-tables-match-statements-and-switch-statements.md | 4 ++-- .../you-can-supply-default-values-for-route-parameters.md | 4 ++-- ...ts-should-be-converted-to-their-string-representation.md | 4 ++-- ...ou-can-use-first-class-callables-for-routes-in-php-81.md | 4 ++-- ...hint-that-an-instance-of-the-passed-class-is-returned.md | 6 +++--- content/tips/you-can-use-onerror-on-the-image-tag.md | 4 ++-- ...tax-to-pass-an-array-of-arguments-to-another-function.md | 4 ++-- 21 files changed, 43 insertions(+), 43 deletions(-) rename content/threads/{weekly-thread-2022-01.md => weekly-thread-2021-01.md} (70%) diff --git a/content/threads/weekly-thread-2022-01.md b/content/threads/weekly-thread-2021-01.md similarity index 70% rename from content/threads/weekly-thread-2022-01.md rename to content/threads/weekly-thread-2021-01.md index 0f46fbf..a44bc77 100644 --- a/content/threads/weekly-thread-2022-01.md +++ b/content/threads/weekly-thread-2021-01.md @@ -1,5 +1,5 @@ --- -slug: weekly-thread-2022-01 +slug: weekly-thread-2021-01 title: 'Weekly thread #01 of 2022' tweet_id: '1479467928818892800' author_username: archtechx @@ -8,4 +8,4 @@ links: { } --- 🔥 Latest code tips for Laravel developers -First week's special: news from the past 3 weeks 🧵 +First week's special: news from the past 3 weeks 🧵 \ No newline at end of file diff --git a/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md index 517ea33..5f6ac5c 100644 --- a/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md +++ b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md @@ -1,7 +1,7 @@ --- title: 'Adding WHERE scopes which use an indexed column to a query that''s primarily filtered by another column is a great way to speed up DB performance' tweet_id: '1471864653491974151' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: tobias_petry images: - 'https://pbs.twimg.com/media/FGafd_JXMAEDgP5.jpg' @@ -10,4 +10,4 @@ slug: adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily --- ⚡️ Database Tip -Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition. +Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition. \ No newline at end of file diff --git a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md index e0b4733..71931e4 100644 --- a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md +++ b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md @@ -1,7 +1,7 @@ --- title: 'Compare models using is() instead of directly comparing attributes' tweet_id: '1479467936700010504' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: archtechx images: - '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 -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 \ No newline at end of file diff --git a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md index 85d4e8e..47711bd 100644 --- a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md +++ b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md @@ -1,7 +1,7 @@ --- title: 'Custom collections pair well with higher order proxies' tweet_id: '1479467951753285637' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: archtechx images: - '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 -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 \ No newline at end of file diff --git a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md index 63c3c45..8b50ce5 100644 --- a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md +++ b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md @@ -1,7 +1,7 @@ --- title: 'From PHP 7.4, you can use the spread syntax to merge arrays' tweet_id: '1479467945822588931' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: bhaidar images: - '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+ -#Laravel +#Laravel \ No newline at end of file diff --git a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md index 12a2e32..335c00d 100644 --- a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md +++ b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md @@ -1,11 +1,11 @@ --- title: 'Number markdown lists with `1.` rather than the actual number' tweet_id: '1479467929888440329' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: frankdejonge images: - 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png' created_at: 2022-01-07T15:00:16+00:00 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 🤘 \ No newline at end of file diff --git a/content/tips/php-81-enums-can-be-used-as-model-casts.md b/content/tips/php-81-enums-can-be-used-as-model-casts.md index 07fb2b1..14000e8 100644 --- a/content/tips/php-81-enums-can-be-used-as-model-casts.md +++ b/content/tips/php-81-enums-can-be-used-as-model-casts.md @@ -1,7 +1,7 @@ --- title: 'PHP 8.1 enums can be used as model casts' tweet_id: '1479467948985126913' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file diff --git a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md index 74b1cd1..2413ebe 100644 --- a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md +++ b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md @@ -1,7 +1,7 @@ --- title: 'Use `composer why-not` to see why a dependency cannot be installed' tweet_id: '1479467931159334915' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: freekmurze images: - '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 --- 🔥 Composer has a `why-not` command that will tell you why it won’t install a particular version of a package -#php +#php \ No newline at end of file diff --git a/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md index ec66634..70c3f7d 100644 --- a/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md +++ b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md @@ -1,13 +1,13 @@ --- title: 'Use match () or switch () statements to conditionally scope database queries based on query strings in the request' tweet_id: '1471864655710670854' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: archtechx images: - 'https://pbs.twimg.com/media/FGmQH5nXEAs4mnv.jpg' created_at: 2021-12-17T15:27:34+00:00 slug: use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request --- -Remembered this great tip recently, and it's nice to see how fast PHP evolves +Remembered this great tip recently, and it's nice to see how fast PHP evolves -The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback ⚡️ https://twitter.com/reinink/status/1233017064492761088 +The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback ⚡️ https://twitter.com/reinink/status/1233017064492761088 \ No newline at end of file diff --git a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md index 72f8dd7..4ebf82b 100644 --- a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md +++ b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md @@ -1,7 +1,7 @@ --- title: 'Use partitions for deleting mass amounts of data' tweet_id: '1479467943276670979' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: tobias_petry images: - 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg' @@ -10,4 +10,4 @@ slug: use-partitions-for-deleting-mass-amounts-of-data --- ⚡ ️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! \ No newline at end of file diff --git a/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md index 7adedfd..ddb53b1 100644 --- a/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md +++ b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md @@ -1,7 +1,7 @@ --- title: 'Use retry() for callbacks that may randomly fail' tweet_id: '1471864638199451648' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: alexjgarrett images: - 'https://pbs.twimg.com/media/FGP3MSQWQAYKjSm.jpg' @@ -12,4 +12,4 @@ slug: use-retry-for-callbacks-that-may-randomly-fail I was hitting a shaky API that sometimes failed. -Here, the retry function tries the callback 3 times, with a 2 second interval in-between retries. +Here, the retry function tries the callback 3 times, with a 2 second interval in-between retries. \ No newline at end of file diff --git a/content/tips/use-skip-when-writing-tests-ahead-of-time.md b/content/tips/use-skip-when-writing-tests-ahead-of-time.md index 39b52a7..f7270d5 100644 --- a/content/tips/use-skip-when-writing-tests-ahead-of-time.md +++ b/content/tips/use-skip-when-writing-tests-ahead-of-time.md @@ -1,7 +1,7 @@ --- title: 'Use skip() when writing tests ahead of time' tweet_id: '1479467933705195521' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: bhaidar images: - '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. -`skip()` accepts a callback too! +`skip()` accepts a callback too! \ No newline at end of file diff --git a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md index 13c2cab..0e717bc 100644 --- a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md +++ b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md @@ -1,7 +1,7 @@ --- title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed' tweet_id: '1479467947634556930' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: justsanjit images: - '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 -#laravelframework #laravel #mysql #sql +#laravelframework #laravel #mysql #sql \ No newline at end of file diff --git a/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md index 062e3cc..6f70135 100644 --- a/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md +++ b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md @@ -1,7 +1,7 @@ --- title: 'You can add a --refresh flag to the artisan down command to send a refresh header to the browser' tweet_id: '1471864676652826626' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: DianaWebdev images: - 'https://pbs.twimg.com/media/FG0dHeBXwAw3bvc.jpg' diff --git a/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md index d9dd5d2..0bf31f8 100644 --- a/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md +++ b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md @@ -1,7 +1,7 @@ --- title: 'You can refactor cluttered if () conditions using lookup tables, match statements, and switch statements' tweet_id: '1471864664661311488' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: archtechx images: - 'https://pbs.twimg.com/media/FGVrAKdVgAIWfwk.jpg' @@ -12,4 +12,4 @@ slug: you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-stateme First: lookup tables 👇 -These are great for refactoring complex conditions with lots of else if () cases +These are great for refactoring complex conditions with lots of else if () cases \ No newline at end of file diff --git a/content/tips/you-can-supply-default-values-for-route-parameters.md b/content/tips/you-can-supply-default-values-for-route-parameters.md index 5da5f1a..36e98bc 100644 --- a/content/tips/you-can-supply-default-values-for-route-parameters.md +++ b/content/tips/you-can-supply-default-values-for-route-parameters.md @@ -1,7 +1,7 @@ --- title: 'You can supply default values for route parameters' tweet_id: '1479467942039285762' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file diff --git a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md index 24dbb6e..9d921da 100644 --- a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md +++ b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md @@ -1,11 +1,11 @@ --- title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation' tweet_id: '1479467939191345152' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: Philo01 images: - 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg' 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 --- -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. \ No newline at end of file diff --git a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md index 3724fb4..94be80f 100644 --- a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md +++ b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md @@ -1,7 +1,7 @@ --- title: 'You can use first class callables for routes in PHP 8.1' tweet_id: '1479467932379799552' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: archtechx images: - '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 -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 \ No newline at end of file diff --git a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md index 36de745..f0393fc 100644 --- a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md +++ b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md @@ -1,7 +1,7 @@ --- title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned' tweet_id: '1479467944581033986' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: freekmurze images: - '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! -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 \ No newline at end of file diff --git a/content/tips/you-can-use-onerror-on-the-image-tag.md b/content/tips/you-can-use-onerror-on-the-image-tag.md index 7b3e8dd..8cfca5f 100644 --- a/content/tips/you-can-use-onerror-on-the-image-tag.md +++ b/content/tips/you-can-use-onerror-on-the-image-tag.md @@ -1,7 +1,7 @@ --- title: 'You can use `onerror` on the image tag' tweet_id: '1479467940726468609' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: JuanDMeGon images: - '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 --- 😲 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. \ No newline at end of file diff --git a/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md index 4356e1e..adbe5df 100644 --- a/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md +++ b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md @@ -1,7 +1,7 @@ --- title: 'You can use the array spread syntax to pass an array of arguments to another function' tweet_id: '1471864644562305025' -thread_slug: weekly-thread-2022-01 +thread_slug: weekly-thread-2021-01 author_username: freekmurze images: - 'https://pbs.twimg.com/media/FGepj8mWQAUf2R_.jpg' @@ -14,4 +14,4 @@ Here’s a self-contained example where we spread the array output of sys_getloa https://github.com/spatie/cpu-load-health-check/blob/70f387d5167c24d4000d825a5bddab2504d557fb/src/CpuLoad.php#L17 -#php +#php \ No newline at end of file From f17995357c6e14f8b83ff686b2541eab17adc746 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 7 Jan 2022 18:37:55 +0100 Subject: [PATCH 6/6] 2021-01 to 2022-01 --- ...els-using-is-instead-of-directly-comparing-attributes.md | 4 ++-- ...ustom-collections-pair-well-with-higher-order-proxies.md | 4 ++-- ...-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md | 4 ++-- ...r-markdown-lists-with-1-rather-than-the-actual-number.md | 4 ++-- content/tips/php-81-enums-can-be-used-as-model-casts.md | 4 ++-- ...r-why-not-to-see-why-a-dependency-cannot-be-installed.md | 4 ++-- .../use-partitions-for-deleting-mass-amounts-of-data.md | 4 ++-- content/tips/use-skip-when-writing-tests-ahead-of-time.md | 4 ++-- ...trings-by-how-they-sound-rather-than-how-theyre-typed.md | 4 ++-- .../you-can-supply-default-values-for-route-parameters.md | 4 ++-- ...ts-should-be-converted-to-their-string-representation.md | 4 ++-- ...ou-can-use-first-class-callables-for-routes-in-php-81.md | 4 ++-- ...hint-that-an-instance-of-the-passed-class-is-returned.md | 6 +++--- content/tips/you-can-use-onerror-on-the-image-tag.md | 4 ++-- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md index 71931e4..e0b4733 100644 --- a/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md +++ b/content/tips/compare-models-using-is-instead-of-directly-comparing-attributes.md @@ -1,7 +1,7 @@ --- title: 'Compare models using is() instead of directly comparing attributes' tweet_id: '1479467936700010504' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219 \ No newline at end of file +This is a simpler version of the tip below https://twitter.com/archtechx/status/1465334771349811219 diff --git a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md index 47711bd..85d4e8e 100644 --- a/content/tips/custom-collections-pair-well-with-higher-order-proxies.md +++ b/content/tips/custom-collections-pair-well-with-higher-order-proxies.md @@ -1,7 +1,7 @@ --- title: 'Custom collections pair well with higher order proxies' tweet_id: '1479467951753285637' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -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 \ No newline at end of file +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 diff --git a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md index 8b50ce5..63c3c45 100644 --- a/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md +++ b/content/tips/from-php-74-you-can-use-the-spread-syntax-to-merge-arrays.md @@ -1,7 +1,7 @@ --- title: 'From PHP 7.4, you can use the spread syntax to merge arrays' tweet_id: '1479467945822588931' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: bhaidar images: - '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+ -#Laravel \ No newline at end of file +#Laravel diff --git a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md index 335c00d..12a2e32 100644 --- a/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md +++ b/content/tips/number-markdown-lists-with-1-rather-than-the-actual-number.md @@ -1,11 +1,11 @@ --- title: 'Number markdown lists with `1.` rather than the actual number' tweet_id: '1479467929888440329' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: frankdejonge images: - 'https://pbs.twimg.com/media/FHNHLM8X0AA6sqs.png' created_at: 2022-01-07T15:00:16+00:00 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 🤘 \ No newline at end of file +💡 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 🤘 diff --git a/content/tips/php-81-enums-can-be-used-as-model-casts.md b/content/tips/php-81-enums-can-be-used-as-model-casts.md index 14000e8..07fb2b1 100644 --- a/content/tips/php-81-enums-can-be-used-as-model-casts.md +++ b/content/tips/php-81-enums-can-be-used-as-model-casts.md @@ -1,7 +1,7 @@ --- title: 'PHP 8.1 enums can be used as model casts' tweet_id: '1479467948985126913' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file +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. diff --git a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md index 2413ebe..74b1cd1 100644 --- a/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md +++ b/content/tips/use-composer-why-not-to-see-why-a-dependency-cannot-be-installed.md @@ -1,7 +1,7 @@ --- title: 'Use `composer why-not` to see why a dependency cannot be installed' tweet_id: '1479467931159334915' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: freekmurze images: - '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 --- 🔥 Composer has a `why-not` command that will tell you why it won’t install a particular version of a package -#php \ No newline at end of file +#php diff --git a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md index 4ebf82b..72f8dd7 100644 --- a/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md +++ b/content/tips/use-partitions-for-deleting-mass-amounts-of-data.md @@ -1,7 +1,7 @@ --- title: 'Use partitions for deleting mass amounts of data' tweet_id: '1479467943276670979' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: tobias_petry images: - 'https://pbs.twimg.com/media/FIQQcQSXwAk2rDy.jpg' @@ -10,4 +10,4 @@ slug: use-partitions-for-deleting-mass-amounts-of-data --- ⚡ ️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! \ No newline at end of file +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! diff --git a/content/tips/use-skip-when-writing-tests-ahead-of-time.md b/content/tips/use-skip-when-writing-tests-ahead-of-time.md index f7270d5..39b52a7 100644 --- a/content/tips/use-skip-when-writing-tests-ahead-of-time.md +++ b/content/tips/use-skip-when-writing-tests-ahead-of-time.md @@ -1,7 +1,7 @@ --- title: 'Use skip() when writing tests ahead of time' tweet_id: '1479467933705195521' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: bhaidar images: - '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. -`skip()` accepts a callback too! \ No newline at end of file +`skip()` accepts a callback too! diff --git a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md index 0e717bc..13c2cab 100644 --- a/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md +++ b/content/tips/use-the-soundex-function-in-mysql-to-compare-strings-by-how-they-sound-rather-than-how-theyre-typed.md @@ -1,7 +1,7 @@ --- title: 'Use the `SOUNDEX()` function in MySQL to compare strings by how they *sound* rather than how they''re typed' tweet_id: '1479467947634556930' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: justsanjit images: - '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 -#laravelframework #laravel #mysql #sql \ No newline at end of file +#laravelframework #laravel #mysql #sql diff --git a/content/tips/you-can-supply-default-values-for-route-parameters.md b/content/tips/you-can-supply-default-values-for-route-parameters.md index 36e98bc..5da5f1a 100644 --- a/content/tips/you-can-supply-default-values-for-route-parameters.md +++ b/content/tips/you-can-supply-default-values-for-route-parameters.md @@ -1,7 +1,7 @@ --- title: 'You can supply default values for route parameters' tweet_id: '1479467942039285762' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: ryangjchandler images: - '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? -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. \ No newline at end of file +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. diff --git a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md index 9d921da..24dbb6e 100644 --- a/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md +++ b/content/tips/you-can-use-bladestringable-to-define-how-specific-objects-should-be-converted-to-their-string-representation.md @@ -1,11 +1,11 @@ --- title: 'You can use Blade::stringable() to define how specific objects should be converted to their string representation' tweet_id: '1479467939191345152' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: Philo01 images: - 'https://pbs.twimg.com/media/FHn41aBXsAAUyar.jpg' 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 --- -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. \ No newline at end of file +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. diff --git a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md index 94be80f..3724fb4 100644 --- a/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md +++ b/content/tips/you-can-use-first-class-callables-for-routes-in-php-81.md @@ -1,7 +1,7 @@ --- title: 'You can use first class callables for routes in PHP 8.1' tweet_id: '1479467932379799552' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: archtechx images: - '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 -I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard \ No newline at end of file +I don't use constructor DI in my apps, so static methods are fine despite feeling a bit non-standard diff --git a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md index f0393fc..36de745 100644 --- a/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md +++ b/content/tips/you-can-use-generic-class-string-annotations-to-hint-that-an-instance-of-the-passed-class-is-returned.md @@ -1,7 +1,7 @@ --- title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned' tweet_id: '1479467944581033986' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: freekmurze images: - '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! -Hat tip to @enunomaduro +Hat tip to @enunomaduro -https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107 \ No newline at end of file +https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107 diff --git a/content/tips/you-can-use-onerror-on-the-image-tag.md b/content/tips/you-can-use-onerror-on-the-image-tag.md index 8cfca5f..7b3e8dd 100644 --- a/content/tips/you-can-use-onerror-on-the-image-tag.md +++ b/content/tips/you-can-use-onerror-on-the-image-tag.md @@ -1,7 +1,7 @@ --- title: 'You can use `onerror` on the image tag' tweet_id: '1479467940726468609' -thread_slug: weekly-thread-2021-01 +thread_slug: weekly-thread-2022-01 author_username: JuanDMeGon images: - '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 --- 😲 TIL: -You can hide an image when it is broken so you don't get that ugly broken image icon from the browser. \ No newline at end of file +You can hide an image when it is broken so you don't get that ugly broken image icon from the browser.