diff --git a/content/authors/alexjgarrett.md b/content/authors/alexjgarrett.md index 0ad88e1..091d752 100644 --- a/content/authors/alexjgarrett.md +++ b/content/authors/alexjgarrett.md @@ -1,5 +1,5 @@ --- username: alexjgarrett -avatar: 'https://pbs.twimg.com/profile_images/1481608755590615042/Z0usTfe-_normal.jpg' +avatar: 'https://pbs.twimg.com/profile_images/1501500078816739329/xDWzyhtN_normal.jpg' name: 'Alex Garrett-Smith' --- diff --git a/content/threads/weekly-thread-2022-13.md b/content/threads/weekly-thread-2022-13.md new file mode 100644 index 0000000..c37a5cd --- /dev/null +++ b/content/threads/weekly-thread-2022-13.md @@ -0,0 +1,11 @@ +--- +slug: weekly-thread-2022-13 +title: 'Weekly thread #13 of 2022' +tweet_id: '1509994014090711041' +author_username: archtechx +created_at: 2022-04-01T20:40:01+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/understand-the-difference-between-fresh-and-refresh-one-returns-a-fresh-new-instance-while-the-other-refreshes-an-existing-instance.md b/content/tips/understand-the-difference-between-fresh-and-refresh-one-returns-a-fresh-new-instance-while-the-other-refreshes-an-existing-instance.md new file mode 100644 index 0000000..eedd872 --- /dev/null +++ b/content/tips/understand-the-difference-between-fresh-and-refresh-one-returns-a-fresh-new-instance-while-the-other-refreshes-an-existing-instance.md @@ -0,0 +1,11 @@ +--- +title: 'Understand the difference between `fresh()` and `refresh()`. One returns a *fresh* new instance, while the other *refreshes* an existing instance' +tweet_id: '1509994020109316096' +thread_slug: weekly-thread-2022-13 +author_username: mattkingshott +images: + - 'https://pbs.twimg.com/media/FPBT9FCXoAUMen2.jpg' +created_at: 2022-04-01T20:40:03+00:00 +slug: understand-the-difference-between-fresh-and-refresh-one-returns-a-fresh-new-instance-while-the-other-refreshes-an-existing-instance +--- +🔥 #Laravel Tip: Ever wondered what the differences are between an Eloquent model’s ‘fresh()’ and ‘refresh()’ methods? Let’s see what each of them do with this little cheatsheet. \ No newline at end of file diff --git a/content/tips/you-can-freeze-time-in-tests.md b/content/tips/you-can-freeze-time-in-tests.md new file mode 100644 index 0000000..89a2f87 --- /dev/null +++ b/content/tips/you-can-freeze-time-in-tests.md @@ -0,0 +1,15 @@ +--- +title: 'You can freeze time in tests' +tweet_id: '1509994017227886594' +thread_slug: weekly-thread-2022-13 +author_username: AshAllenDesign +images: + - 'https://pbs.twimg.com/media/FO8k5kAWYAAip2V.jpg' +created_at: 2022-04-01T20:40:02+00:00 +slug: you-can-freeze-time-in-tests +--- +❄️In your Laravel tests, you might sometimes need to freeze the time. + +This is particularly useful if you're trying to make assertions based on timestamps or need to make queries based on dates and/or times. + +#laravel #php \ No newline at end of file diff --git a/content/tips/you-can-now-call-newline-on-stringable-instances.md b/content/tips/you-can-now-call-newline-on-stringable-instances.md new file mode 100644 index 0000000..5ae51ba --- /dev/null +++ b/content/tips/you-can-now-call-newline-on-stringable-instances.md @@ -0,0 +1,14 @@ +--- +title: 'You can now call `newLine()` on Stringable instances' +tweet_id: '1509994032033804290' +thread_slug: weekly-thread-2022-13 +author_username: djgeisi +images: + - 'https://pbs.twimg.com/media/FPCdrxkWUAASAm5.jpg' +created_at: 2022-04-01T20:40:06+00:00 +slug: you-can-now-call-newline-on-stringable-instances +--- +#PHP #Laravel +Since todays Laravel 9.6 release a new newline() method was added to the Stringable Class. + +Thanks to @paulandroshchuk who contributed this \ No newline at end of file diff --git a/content/tips/you-can-queue-closures.md b/content/tips/you-can-queue-closures.md new file mode 100644 index 0000000..fdb4397 --- /dev/null +++ b/content/tips/you-can-queue-closures.md @@ -0,0 +1,11 @@ +--- +title: 'You can queue Closures' +tweet_id: '1509994028997169158' +thread_slug: weekly-thread-2022-13 +author_username: alexjgarrett +images: + - 'https://pbs.twimg.com/media/FO7OX-ZX0AEQooG.jpg' +created_at: 2022-04-01T20:40:05+00:00 +slug: you-can-queue-closures +--- +I had no idea you could queue closures in @laravelphp until today. \ No newline at end of file diff --git a/content/tips/you-can-transform-variables-passed-to-translation-strings-right-in-language-files.md b/content/tips/you-can-transform-variables-passed-to-translation-strings-right-in-language-files.md new file mode 100644 index 0000000..dfeba15 --- /dev/null +++ b/content/tips/you-can-transform-variables-passed-to-translation-strings-right-in-language-files.md @@ -0,0 +1,11 @@ +--- +title: 'You can transform variables passed to translation strings right in language files' +tweet_id: '1509994034877534212' +thread_slug: weekly-thread-2022-13 +author_username: ecrmnn +images: + - 'https://pbs.twimg.com/media/FPB_HCDXsAUhtvh.jpg' +created_at: 2022-04-01T20:40:06+00:00 +slug: you-can-transform-variables-passed-to-translation-strings-right-in-language-files +--- +Did you know that translation variables can easily be capitalized or converterd to lowercase and uppcase in Laravel? 🆙🌍 \ No newline at end of file diff --git a/content/tips/you-can-use-constrained-eager-loading-to-increase-performance-of-database-queries-that-use-relations.md b/content/tips/you-can-use-constrained-eager-loading-to-increase-performance-of-database-queries-that-use-relations.md new file mode 100644 index 0000000..2d9e69f --- /dev/null +++ b/content/tips/you-can-use-constrained-eager-loading-to-increase-performance-of-database-queries-that-use-relations.md @@ -0,0 +1,11 @@ +--- +title: 'You can use constrained eager loading to increase performance of database queries that use relations' +tweet_id: '1509994025926885381' +thread_slug: weekly-thread-2022-13 +author_username: mattkingshott +images: + - 'https://pbs.twimg.com/media/FOsQc3JXEAgF1P6.jpg' +created_at: 2022-04-01T20:40:04+00:00 +slug: you-can-use-constrained-eager-loading-to-increase-performance-of-database-queries-that-use-relations +--- +🔥 #Laravel Tip: Eager loading a model’s relationships is a great way to improve performance / avoid the N+1 problem. However, you can go further… with constrained eager loading you can tell Laravel to only load the related records you actually need. \ No newline at end of file diff --git a/content/tips/you-can-use-notificationassertnothingsentto-to-check-that-no-notifications-were-sent-to-a-specific-usernotifiable-model.md b/content/tips/you-can-use-notificationassertnothingsentto-to-check-that-no-notifications-were-sent-to-a-specific-usernotifiable-model.md new file mode 100644 index 0000000..619a2fa --- /dev/null +++ b/content/tips/you-can-use-notificationassertnothingsentto-to-check-that-no-notifications-were-sent-to-a-specific-usernotifiable-model.md @@ -0,0 +1,15 @@ +--- +title: 'You can use `Notification::assertNothingSentTo()` to check that no notifications were sent to a specific user/notifiable model' +tweet_id: '1509994037830332416' +thread_slug: weekly-thread-2022-13 +author_username: AshAllenDesign +images: + - 'https://pbs.twimg.com/media/FO8nW9TXsBExZTp.jpg' +created_at: 2022-04-01T20:40:07+00:00 +slug: you-can-use-notificationassertnothingsentto-to-check-that-no-notifications-were-sent-to-a-specific-usernotifiable-model +--- +🚀 You can now use the new "assertNothingSentTo" method in your Laravel tests. + +You can use this to ensure that no notifications were sent to a given notifiable model (or models)! + +#laravel #php \ No newline at end of file diff --git a/content/tips/you-can-use-use-wherebetween-to-filter-for-records-between-two-timestamps.md b/content/tips/you-can-use-use-wherebetween-to-filter-for-records-between-two-timestamps.md new file mode 100644 index 0000000..ebe4813 --- /dev/null +++ b/content/tips/you-can-use-use-wherebetween-to-filter-for-records-between-two-timestamps.md @@ -0,0 +1,11 @@ +--- +title: 'You can use use `whereBetween` to filter for records between two timestamps' +tweet_id: '1509994023083147264' +thread_slug: weekly-thread-2022-13 +author_username: ecrmnn +images: + - 'https://pbs.twimg.com/media/FO8rgMGXsAkX0SD.jpg' +created_at: 2022-04-01T20:40:04+00:00 +slug: you-can-use-use-wherebetween-to-filter-for-records-between-two-timestamps +--- +How to retrieve records between two timestamps in Laravel 🗓 Use whereBetween with a from and to date. If you need to provide fallback you can do so with the nullish coalescing operator ❔❔ \ No newline at end of file