1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00

Weekly thread #7

This commit is contained in:
lukinovec 2022-02-21 16:15:07 +01:00
parent 2065cd1268
commit 91cf331b3b
7 changed files with 79 additions and 0 deletions

View file

@ -0,0 +1,11 @@
---
slug: weekly-thread-2022-07
title: 'Weekly thread #07 of 2022'
tweet_id: '1495414929053995012'
author_username: archtechx
created_at: 2022-02-20T15:07:57+00:00
links: { }
---
🔥 This week's code tips for Laravel developers
A weekly thread 🧵

View file

@ -0,0 +1,11 @@
---
title: 'Move tests to separate test suites'
tweet_id: '1495414937757253636'
thread_slug: weekly-thread-2022-07
author_username: JackEllis
images:
- 'https://pbs.twimg.com/media/FLVuSJRVQAEQffe.jpg'
created_at: 2022-02-20T15:07:59+00:00
slug: move-tests-to-separate-test-suites
---
My Laravel tip of the day. If you're running slow tests that need to hit a third party API, you can break them out of your Features directory and put them in a dedicated test suite (e.g. External). Then you can run "phpunit --testsuite Feature", and your External tests won't run.

View file

@ -0,0 +1,11 @@
---
title: 'Use comments for explaining complex logic'
tweet_id: '1495414946556903424'
thread_slug: weekly-thread-2022-07
author_username: brendt_gd
images:
- 'https://pbs.twimg.com/media/FLsw0t6XwAIe5aI.jpg'
created_at: 2022-02-20T15:08:01+00:00
slug: use-comments-for-explaining-complex-logic
---
Comments in code should be used with care. They should only be added when they add actual value to the programmer; which is why I style them in such a way that they "pop out", instead of them disappearing in the background.

View file

@ -0,0 +1,11 @@
---
title: 'Use Faker::numerify() to create strings with numbers at specific places'
tweet_id: '1495414931788746755'
thread_slug: weekly-thread-2022-07
author_username: SteveTheBauman
images:
- 'https://pbs.twimg.com/media/FLkESRpXIAwj769.jpg'
created_at: 2022-02-20T15:07:57+00:00
slug: use-fakernumerify-to-create-strings-with-numbers-at-specific-places
---
A quick one that I *always* forget about -- Faker::numerify, allowing you to generate numeric data in a specific pattern 👌👏

View file

@ -0,0 +1,11 @@
---
title: 'You can conditionally skip() scheduled jobs'
tweet_id: '1495414940684804100'
thread_slug: weekly-thread-2022-07
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FL2KtKzVgAABGiG.jpg'
created_at: 2022-02-20T15:07:59+00:00
slug: you-can-conditionally-skip-scheduled-jobs
---
🔥 #Laravel the skip method in scheduler

View file

@ -0,0 +1,13 @@
---
title: 'You can use traits inside PHP enums'
tweet_id: '1495414934754136064'
thread_slug: weekly-thread-2022-07
author_username: archtechx
images:
- 'https://pbs.twimg.com/media/FL_ee0mVgAUuD-u.jpg'
created_at: 2022-02-20T15:07:58+00:00
slug: you-can-use-traits-inside-php-enums
---
A few days ago, I learned that PHP enums can use traits
It may seem like a massive anti-pattern, but it allows making enums actually awesome with this one trick 🔥

View file

@ -0,0 +1,11 @@
---
title: 'You can use whereNumber() on routes instead of passing a regex pattern to where()'
tweet_id: '1495414943612506113'
thread_slug: weekly-thread-2022-07
author_username: Sileence
images:
- 'https://pbs.twimg.com/media/FLZ9iNEX0AcKQVD.jpg'
created_at: 2022-02-20T15:08:00+00:00
slug: you-can-use-wherenumber-on-routes-instead-of-passing-a-regex-pattern-to-where
---
I'm reading the Laravel 9 docs from scratch and TIL you can write your route restrictions in a more expressive way: