1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-11 21:14:02 +00:00

Week 12/2022

This commit is contained in:
lukinovec 2022-03-26 13:32:34 +01:00
parent b451d14953
commit a913dd94aa
14 changed files with 144 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
username: laravelnews
name: 'Laravel News'
avatar: 'https://pbs.twimg.com/profile_images/1359866716222861317/coQ-RmRS_normal.jpg'
---

View file

@ -1,5 +1,5 @@
---
username: ryangjchandler
avatar: 'https://pbs.twimg.com/profile_images/1507600871370391557/Em6_vfLo_normal.png'
name: 'Ryan Chandler'
avatar: 'https://pbs.twimg.com/profile_images/1446231529986961410/X5zL_n0h_normal.jpg'
---

View file

@ -0,0 +1,5 @@
---
username: zepfietje
name: 'Zep Fietje'
avatar: 'https://pbs.twimg.com/profile_images/1486773319189815314/VstRGufn_normal.jpg'
---

View file

@ -0,0 +1,11 @@
---
slug: weekly-thread-2022-12
title: 'Weekly thread #12 of 2022'
tweet_id: '1507455535322308610'
author_username: archtechx
created_at: 2022-03-25T20:33:01+00:00
links: { }
---
🔥 This week's code tips for Laravel developers
A weekly thread 🧵

View file

@ -0,0 +1,14 @@
---
title: 'If you use both pest and PHPUnit, you can use both syntaxes in both types of tests'
tweet_id: '1507455564942495749'
thread_slug: weekly-thread-2022-12
author_username: djgeisi
images:
- 'https://pbs.twimg.com/media/FOUNAdFXMAQI7RA.jpg'
created_at: 2022-03-25T20:33:08+00:00
slug: if-you-use-both-pest-and-phpunit-you-can-use-both-syntaxes-in-both-types-of-tests
---
#PestPHP #PHP Tip
If you have a mixed codebase with Pest and PHPUnit tests you can use almost all of the pest magic in your PHPUnit tests.
It just works.

View file

@ -0,0 +1,11 @@
---
title: 'isset() accepts multiple arguments'
tweet_id: '1507455541072728066'
thread_slug: weekly-thread-2022-12
author_username: laravelnews
images:
- 'https://pbs.twimg.com/media/FOqbrYAX0AgsSNL.jpg'
created_at: 2022-03-25T20:33:02+00:00
slug: isset-accepts-multiple-arguments
---
It's a minor thing but the PHP `isset` function can accept multiple vars. https://www.instagram.com/p/CbctwMxgPv4/

View file

@ -0,0 +1,11 @@
---
title: 'Pest allows calling dd() directly on the expect() chain'
tweet_id: '1507455561918390279'
thread_slug: weekly-thread-2022-12
author_username: enunomaduro
images:
- 'https://pbs.twimg.com/media/FOibegNXsAEKTbb.jpg'
created_at: 2022-03-25T20:33:07+00:00
slug: pest-allows-calling-dd-directly-on-the-expect-chain
---
Pest tip: Use the `dd` method to dump the current expectation value and end the test suite. 🔦

View file

@ -0,0 +1,13 @@
---
title: 'Use the `ShouldBeEncrypted` interface on a job class to make Laravel encrypt the job''s payload'
tweet_id: '1507455546978287617'
thread_slug: weekly-thread-2022-12
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FOG28lHUcAAk6Om.jpg'
created_at: 2022-03-25T20:33:04+00:00
slug: use-the-shouldbeencrypted-interface-on-a-job-class-to-make-laravel-encrypt-the-jobs-payload
---
🔥 #Laravel Job Encryption
Since Laravel v8.19.0, you can add the `ShouldBeEncrypted` interface to your job class. Laravel will encrypt the job's payload automatically.

View file

@ -0,0 +1,11 @@
---
title: 'You can clear all Laravel caches using `optimize:clear`'
tweet_id: '1507455552892268546'
thread_slug: weekly-thread-2022-12
author_username: aschmelyun
images:
- 'https://pbs.twimg.com/media/FOeOo81WYAUa42D.jpg'
created_at: 2022-03-25T20:33:05+00:00
slug: you-can-clear-all-laravel-caches-using-optimizeclear
---
Just found out there's a single artisan command to clear out all Laravel caches, much less typing!

View file

@ -0,0 +1,16 @@
---
title: 'You can debounce a function using Alpine.debounce()'
tweet_id: '1507455555899564032'
thread_slug: weekly-thread-2022-12
author_username: zepfietje
images: { }
created_at: 2022-03-25T20:33:06+00:00
slug: you-can-debounce-a-function-using-alpinedebounce
---
❓ Using Alpine.js and need to debounce a function?
❌ You don't need JavaScript libraries like lodash.
✅ Just use Alpine.debounce() which is also used internally for the x-on:input.debounce="" modifier.
Cc: @calebporzio

View file

@ -0,0 +1,13 @@
---
title: 'You can generate a series of dates in a given range right at the database level'
tweet_id: '1507455559049822208'
thread_slug: weekly-thread-2022-12
author_username: tobias_petry
images:
- 'https://pbs.twimg.com/media/FOih4zwWQAsjZ-E.jpg'
created_at: 2022-03-25T20:33:07+00:00
slug: you-can-generate-a-series-of-dates-in-a-given-range-right-at-the-database-level
---
⚡️ Database Tip
When doing statistical aggregations by time, you may have gaps in your data. You don't have to fill them manually with code! You can generate a series of dates from a start to end time and use these days to join to your statistical data with gaps.

View file

@ -0,0 +1,11 @@
---
title: 'You can record all login & logout events'
tweet_id: '1507455544021250049'
thread_slug: weekly-thread-2022-12
author_username: mattkingshott
images:
- 'https://pbs.twimg.com/media/FOoOjf-XIAMPLIW.jpg'
created_at: 2022-03-25T20:33:03+00:00
slug: you-can-record-all-login-logout-events
---
🔥 #Laravel Tip: If your app needs to record logins and logouts for security purposes (auditing), then you should definitely make use of the auth events, which allow you to easily listen for them.

View file

@ -0,0 +1,11 @@
---
title: 'You can remove all falsy values from a Collection by calling filter() without any arguments'
tweet_id: '1507455538078003203'
thread_slug: weekly-thread-2022-12
author_username: ecrmnn
images:
- 'https://pbs.twimg.com/media/FOYvPYuWQAoA-2P.jpg'
created_at: 2022-03-25T20:33:02+00:00
slug: you-can-remove-all-falsy-values-from-a-collection-by-calling-filter-without-any-arguments
---
Laravel Collections tip. To remove all falsy values from the collection, simply call filter without any arguments ✨

View file

@ -0,0 +1,11 @@
---
title: 'You can start testing Livewire components with basic tests that makes sure components render accurately'
tweet_id: '1507455550027563009'
thread_slug: weekly-thread-2022-12
author_username: ryangjchandler
images:
- 'https://pbs.twimg.com/media/FOPGoowXEAE883f.jpg'
created_at: 2022-03-25T20:33:04+00:00
slug: you-can-start-testing-livewire-components-with-basic-tests-that-makes-sure-components-render-accurately
---
🔥 When you're testing your @LaravelLivewire components, one of the simplest tests you can add is a "can this component be mounted" test. This is one of the best ways to test your the mounting process in isolation and ensuring the component renders the view correctly.