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