diff --git a/content/authors/LiamHammett.md b/content/authors/LiamHammett.md index 1c4f262..d24ce88 100644 --- a/content/authors/LiamHammett.md +++ b/content/authors/LiamHammett.md @@ -1,5 +1,5 @@ --- username: LiamHammett name: 'Liam Hammett' -avatar: 'https://pbs.twimg.com/profile_images/1236048705297485837/oGeWeWid_normal.jpg' +avatar: 'https://pbs.twimg.com/profile_images/1436690674833891341/vOl5qtiA_normal.jpg' --- diff --git a/content/threads/weekly-thread-2021-49.md b/content/threads/weekly-thread-2021-49.md new file mode 100644 index 0000000..dd35bac --- /dev/null +++ b/content/threads/weekly-thread-2021-49.md @@ -0,0 +1,11 @@ +--- +slug: weekly-thread-2021-49 +title: 'Weekly thread #49 of 2021' +tweet_id: '1469321059585331201' +author_username: archtechx +created_at: 2021-12-10T15:22:03+00:00 +links: { } +--- +πŸ”₯ This week's code tips for Laravel developers + +🧡 A weekly thread \ No newline at end of file diff --git a/content/tips/if-youre-returning-class-names-as-opposed-to-instances-you-can-use-the-class-name-docblock.md b/content/tips/if-youre-returning-class-names-as-opposed-to-instances-you-can-use-the-class-name-docblock.md new file mode 100644 index 0000000..9d9898b --- /dev/null +++ b/content/tips/if-youre-returning-class-names-as-opposed-to-instances-you-can-use-the-class-name-docblock.md @@ -0,0 +1,14 @@ +--- +title: 'If you''re returning class names (as opposed to instances), you can use the class-name docblock' +tweet_id: '1469321064668753921' +thread_slug: weekly-thread-2021-49 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FGFgPPKWYAoNJB9.jpg' +created_at: 2021-12-10T15:00:15+00:00 +slug: if-youre-returning-class-names-as-opposed-to-instances-you-can-use-the-class-name-docblock +--- +If you’re returning a fully qualified class name, you can use the `class-name` docblock. You can specify a base class or interface between `<>` + +And of course, you can also return an array of `class-name`s too πŸ‘ +#php \ No newline at end of file diff --git a/content/tips/keep-validation-rules-inside-models-to-make-your-code-more-consistent-and-clean.md b/content/tips/keep-validation-rules-inside-models-to-make-your-code-more-consistent-and-clean.md new file mode 100644 index 0000000..259dc7e --- /dev/null +++ b/content/tips/keep-validation-rules-inside-models-to-make-your-code-more-consistent-and-clean.md @@ -0,0 +1,14 @@ +--- +title: 'Keep validation rules inside models to make your code more consistent and clean' +tweet_id: '1469321060604514304' +thread_slug: weekly-thread-2021-49 +author_username: archtechx +images: { } +created_at: 2021-12-10T15:00:14+00:00 +slug: keep-validation-rules-inside-models-to-make-your-code-more-consistent-and-clean +--- +This pattern is brilliant and can make your code much more clean and consistent + +The tweet is from last year, but it's still very relevant + +https://twitter.com/LiamHammett/status/1260252814158282752 \ No newline at end of file diff --git a/content/tips/this-pattern-is-brilliant-and-can-make-your-code-much-more-clean-and-consistent.md b/content/tips/this-pattern-is-brilliant-and-can-make-your-code-much-more-clean-and-consistent.md new file mode 100644 index 0000000..2fbb195 --- /dev/null +++ b/content/tips/this-pattern-is-brilliant-and-can-make-your-code-much-more-clean-and-consistent.md @@ -0,0 +1,11 @@ +--- +title: 'This pattern is brilliant and can make your code much more clean and consistent' +tweet_id: '1468596267458588676' +thread_slug: weekly-thread-2021-49 +author_username: LiamHammett +images: + - 'https://pbs.twimg.com/media/EX1RMP1X0AApuv6.jpg' +created_at: 2021-12-08T15:00:10+00:00 +slug: this-pattern-is-brilliant-and-can-make-your-code-much-more-clean-and-consistent +--- +πŸ”₯ I often find myself keeping validation rules in a method on the model. This lets me reuse them wherever I may need - including in controllers or form requests. \ No newline at end of file diff --git a/content/tips/use-typehints-wherever-possible-to-improve-code-safety-and-ide-support.md b/content/tips/use-typehints-wherever-possible-to-improve-code-safety-and-ide-support.md new file mode 100644 index 0000000..a2b3d5a --- /dev/null +++ b/content/tips/use-typehints-wherever-possible-to-improve-code-safety-and-ide-support.md @@ -0,0 +1,18 @@ +--- +title: 'Use typehints wherever possible to improve code safety and IDE support' +tweet_id: '1469321063242731523' +thread_slug: weekly-thread-2021-49 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FGFJmbVVQAEv_oj.jpg' +created_at: 2021-12-10T15:00:14+00:00 +slug: use-typehints-wherever-possible-to-improve-code-safety-and-ide-support +--- +πŸ”₯ Simple typehints and annotations go a long way + +Even without any docblocks, this code is perfectly understandable by both developers and IDEs + +Writing code like this: +πŸ‘‰ Prevents bugs using type safety +πŸ‘‰ Makes the code self-documenting +πŸ‘‰ Takes only a few seconds to implement \ No newline at end of file diff --git a/content/tips/writing-simple-page-can-be-visited-tests-is-a-great-way-to-get-started-with-testing.md b/content/tips/writing-simple-page-can-be-visited-tests-is-a-great-way-to-get-started-with-testing.md new file mode 100644 index 0000000..ddc64e4 --- /dev/null +++ b/content/tips/writing-simple-page-can-be-visited-tests-is-a-great-way-to-get-started-with-testing.md @@ -0,0 +1,14 @@ +--- +title: 'Writing simple "page can be visited" tests is a great way to get started with testing' +tweet_id: '1469321067399303170' +thread_slug: weekly-thread-2021-49 +author_username: enunomaduro +images: + - 'https://pbs.twimg.com/media/FGKWEIlXoAIpBiR.jpg' +created_at: 2021-12-10T15:00:15+00:00 +slug: writing-simple-page-can-be-visited-tests-is-a-great-way-to-get-started-with-testing +--- +Does your @laravelphp application have 0 tests? Here is one test you can easily add to get started. It's probably the most important test β€” in web projects β€” and it has an enormous value. + +βœ“ Ensures your application boots. βœ… +βœ“ Ensures the home page can be loaded. πŸ’¨ \ No newline at end of file diff --git a/content/tips/you-can-add-a-messages-method-to-form-requests-to-customize-their-validation-error-messages.md b/content/tips/you-can-add-a-messages-method-to-form-requests-to-customize-their-validation-error-messages.md new file mode 100644 index 0000000..0f23e91 --- /dev/null +++ b/content/tips/you-can-add-a-messages-method-to-form-requests-to-customize-their-validation-error-messages.md @@ -0,0 +1,13 @@ +--- +title: 'You can add a messages() method to form requests to customize their validation error messages' +tweet_id: '1469321068632444928' +thread_slug: weekly-thread-2021-49 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FF2CRarXEAMNqZg.jpg' + - 'https://pbs.twimg.com/media/FF2CRdRXEAEpXNV.jpg' +created_at: 2021-12-10T15:00:16+00:00 +slug: you-can-add-a-messages-method-to-form-requests-to-customize-their-validation-error-messages +--- +❌ To customise a validation message for a request in @laravelphp , you can add a `message` function to a form request. Very handy! +#laravel #php \ No newline at end of file diff --git a/content/tips/you-can-calculate-multiple-aggregates-in-a-single-database-query.md b/content/tips/you-can-calculate-multiple-aggregates-in-a-single-database-query.md new file mode 100644 index 0000000..8f5a89b --- /dev/null +++ b/content/tips/you-can-calculate-multiple-aggregates-in-a-single-database-query.md @@ -0,0 +1,13 @@ +--- +title: 'You can calculate multiple aggregates in a single database query' +tweet_id: '1469321061955108864' +thread_slug: weekly-thread-2021-49 +author_username: tobias_petry +images: + - 'https://pbs.twimg.com/media/FF5qzyXXwAc445P.jpg' +created_at: 2021-12-10T15:00:14+00:00 +slug: you-can-calculate-multiple-aggregates-in-a-single-database-query +--- +⚑️ Database Tip + +You don't have to execute multiple queries to calculate different aggregates. With the filter clause you can narrow the rows which should be included for the calculation. So you may need to scan the table only once, the performance impact can be massive πŸ”₯ \ No newline at end of file diff --git a/content/tips/you-can-use-request-whenfilled-to-execute-some-logic-only-when-a-specific-value-is-part-of-the-request-data.md b/content/tips/you-can-use-request-whenfilled-to-execute-some-logic-only-when-a-specific-value-is-part-of-the-request-data.md new file mode 100644 index 0000000..a67302e --- /dev/null +++ b/content/tips/you-can-use-request-whenfilled-to-execute-some-logic-only-when-a-specific-value-is-part-of-the-request-data.md @@ -0,0 +1,17 @@ +--- +title: 'You can use $request->whenFilled() to execute some logic only when a specific value is part of the request data' +tweet_id: '1469321066182955010' +thread_slug: weekly-thread-2021-49 +author_username: mmartin_joo +images: + - 'https://pbs.twimg.com/media/FF38VhkXsAAv0VW.png' +created_at: 2021-12-10T15:00:15+00:00 +slug: you-can-use-request-whenfilled-to-execute-some-logic-only-when-a-specific-value-is-part-of-the-request-data +--- +πŸ”₯Another amazing #Laravel feature!πŸ”₯ + +We often write if statements to check if a value is present on a request or not. + +You can simplify it with the whenFilled() helper. + +πŸ‘‹If you find this useful, consider clicking the button that says Retweet. It's a very cool button!