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

Week 15 of 2022

This commit is contained in:
Samuel Štancl 2022-04-17 20:03:34 +02:00
parent 105099cea8
commit 3ed17d8cef
7 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,15 @@
---
title: 'Improve the DX of your commands by making arguments optional and prompting the user when they''re empty'
tweet_id: '1515057387027140609'
thread_slug: weekly-thread-2022-15
author_username: mmartin_joo
images:
- 'https://pbs.twimg.com/media/FQAcwOkWUAESOwS.jpg'
created_at: 2022-04-15T20:00:04+00:00
slug: improve-the-dx-of-your-commands-by-making-arguments-optional-and-prompting-the-user-when-theyre-empty
---
💡 Just a quick tip: define every argument of commands as optional and ask for input if they are missing.
This way, you dont need to think about the arguments when running a command.
Just run it, and it will ask everything:

View file

@ -0,0 +1,11 @@
---
title: 'In scheduled tasks, you can use `onSuccess` and `onFailure` callbacks'
tweet_id: '1515057395763798018'
thread_slug: weekly-thread-2022-15
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FQAK8H-XEAMWMMT.jpg'
created_at: 2022-04-15T20:00:06+00:00
slug: in-scheduled-tasks-you-can-use-onsuccess-and-onfailure-callbacks
---
🔥 Laravel Tip: You can specify what to do if a scheduled task fails or succeeds.

View file

@ -0,0 +1,13 @@
---
title: 'The `shouldCache()` method lets you cache model accessor values'
tweet_id: '1515057389950537729'
thread_slug: weekly-thread-2022-15
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FQOpEt5VQA0OnWt.jpg'
created_at: 2022-04-15T20:00:04+00:00
slug: the-shouldcache-method-lets-you-cache-model-accessor-values
---
🔥 Laravel Tip: Accessor Caching
As of Laravel 9.6, if you have a computationally intensive accessor, you can use the shouldCache method.

View file

@ -0,0 +1,11 @@
---
title: 'The spread syntax understands named parameters and correctly assigns array values to them'
tweet_id: '1515057384204382208'
thread_slug: weekly-thread-2022-15
author_username: SteveTheBauman
images:
- 'https://pbs.twimg.com/media/FQJ4FUcX0A01ZUZ.jpg'
created_at: 2022-04-15T20:00:03+00:00
slug: the-spread-syntax-understands-named-parameters-and-correctly-assigns-array-values-to-them
---
Today I learned that PHP will insert callback parameters in the order of their defined name, when spreading an array of args with string keys, allowing you to place them in any position in the callback. Super cool! 💪

View file

@ -0,0 +1,11 @@
---
title: 'You can generate fake images using Faker'
tweet_id: '1515057392890769410'
thread_slug: weekly-thread-2022-15
author_username: justsanjit
images:
- 'https://pbs.twimg.com/media/FQOhGy6XEAMYB-X.jpg'
created_at: 2022-04-15T20:00:05+00:00
slug: you-can-generate-fake-images-using-faker
---
#Laravel #PHP Tip 🔥 You can use #faker to not only generate text values but also fake images.

View file

@ -0,0 +1,11 @@
---
title: 'You can process the output of scheduled tasks: send an email or write to a file'
tweet_id: '1515057398687313920'
thread_slug: weekly-thread-2022-15
author_username: justsanjit
images:
- 'https://pbs.twimg.com/media/FQHMYW4WQAIxF69.jpg'
created_at: 2022-04-15T20:00:06+00:00
slug: you-can-process-the-output-of-scheduled-tasks-send-an-email-or-write-to-a-file
---
#Laravel Tip 🔥 Few convenient methods to work with the output of scheduled tasks.