mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
Weekly thread #5-#7, use actual created_at timestamp in Thread creation (#27)
* Weekly thread #5 * Weekly thread #6 (before #5) * Weekly thread #5 * Correct the weekly thread created_at timestamps * Add actual created_at to Thread * Weekly thread #7 * Fix weekly thread #7 * Remove thread #8
This commit is contained in:
parent
e907eba3dd
commit
1a53831d4d
38 changed files with 363 additions and 3 deletions
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'In Laravel 9, you can use str() instead of Str::of()'
|
||||
tweet_id: '1494019557249335296'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: jasonlbeggs
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLKjhn4XMAIZqNI.png'
|
||||
created_at: 2022-02-16T18:43:14+00:00
|
||||
slug: in-laravel-9-you-can-use-str-instead-of-strof
|
||||
---
|
||||
The `str` helper in @laravelphp v9 is 🔥
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 'Laravel 9 can automatically bind route parameters to enums'
|
||||
tweet_id: '1494019551310139392'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: mmartin_joo
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLJ8Gt_XsAM98uy.jpg'
|
||||
created_at: 2022-02-16T18:43:13+00:00
|
||||
slug: laravel-9-can-automatically-bind-route-parameters-to-enums
|
||||
---
|
||||
🔥Laravel 9 introduced enum route bindings!
|
||||
|
||||
You can type-hint your enum and Laravel will cast the string value from the URL:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
title: 'Laravel provides a `Fluent` class as a universal structure for array data'
|
||||
tweet_id: '1489620180086902792'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: cerbero90
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKcMWbwacAICnCw.png'
|
||||
created_at: 2022-02-04T15:21:41+00:00
|
||||
slug: laravel-provides-a-fluent-class-as-a-universal-structure-for-array-data
|
||||
---
|
||||
Fluent is a utility class provided by @laravelphp that lets us handle data fluently.
|
||||
|
||||
Out of the box it can be turned into an array or JSON, it can act as an array and it's serializable as a JSON.
|
||||
|
||||
It also gets and sets attributes dynamically and in a fluent way.
|
||||
|
||||
#Laravel #PHP
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'match() statements are a great way to clean up code'
|
||||
tweet_id: '1489620168233734144'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: cerbero90
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKqzQ68aMAAqGdX.png'
|
||||
created_at: 2022-02-04T15:21:38+00:00
|
||||
slug: match-statements-are-a-great-way-to-clean-up-code
|
||||
---
|
||||
Match offers such a compact and clean syntax compared to its PHP alternatives 🌈
|
||||
|
||||
It can make our code way more readable and concise 💅
|
||||
|
||||
#PHP
|
||||
11
content/tips/move-tests-to-separate-test-suites.md
Normal file
11
content/tips/move-tests-to-separate-test-suites.md
Normal 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.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'Name contracts as descriptors and implementations as orders'
|
||||
tweet_id: '1494019563490402305'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: MikeVILT
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLKZjZbXMAQ18WD.jpg'
|
||||
created_at: 2022-02-16T18:43:16+00:00
|
||||
slug: name-contracts-as-descriptors-and-implementations-as-orders
|
||||
---
|
||||
A great tip from Luke @LukeDowning19,
|
||||
|
||||
"Name contracts as descriptions and implementations as orders"
|
||||
|
||||
#laracon
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: 'Specify container bindings using the $bindings array'
|
||||
tweet_id: '1494019548374126594'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: freekmurze
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLKZmOCWYAAq9Hd.jpg'
|
||||
created_at: 2022-02-16T18:43:12+00:00
|
||||
slug: specify-container-bindings-using-the-bindings-array
|
||||
---
|
||||
🔥 Cool tidbit I learned during @LukeDowning19 ’s talk.
|
||||
|
||||
You can add a `$bindings` array to a service provider to bind things.
|
||||
|
||||
https://laravel.com/docs/9.x/providers#the-bindings-and-singletons-properties
|
||||
#laravel #php
|
||||
11
content/tips/use-comments-for-explaining-complex-logic.md
Normal file
11
content/tips/use-comments-for-explaining-complex-logic.md
Normal 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.
|
||||
|
|
@ -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 👌👏
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 'Use the policy() helper to resolve a policy for a model'
|
||||
tweet_id: '1494019545446567939'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: asantibanez
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FLNAs-bXIAExJxr.jpg'
|
||||
created_at: 2022-02-16T18:43:11+00:00
|
||||
slug: use-the-policy-helper-to-resolve-a-policy-for-a-model
|
||||
---
|
||||
TIL about @laravelphp policy() helper. Give it a model and it will resolve the policy for you.
|
||||
|
||||
Very useful when testing policies behavior. 💪
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'You can add this Tailwind plugin to generate child-selector variants'
|
||||
tweet_id: '1489620177071210497'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: warsh33p
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKaHaf9XsAQzC_0.jpg'
|
||||
created_at: 2022-02-04T15:21:40+00:00
|
||||
slug: you-can-add-this-tailwind-plugin-to-generate-child-selector-variants
|
||||
---
|
||||
🔥 Since I’m having to deal with a lot of generated markup recently, this small child-selector plugin for Tailwind has been a life saver.
|
||||
11
content/tips/you-can-conditionally-skip-scheduled-jobs.md
Normal file
11
content/tips/you-can-conditionally-skip-scheduled-jobs.md
Normal 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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'You can disable lazy loading using Model::preventLazyLoading()'
|
||||
tweet_id: '1489620165201330177'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: mattkingshott
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKlnRQ_XwAUqAxB.jpg'
|
||||
created_at: 2022-02-04T15:21:37+00:00
|
||||
slug: you-can-disable-lazy-loading-using-modelpreventlazyloading
|
||||
---
|
||||
🔥 #Laravel Tip: Protect your database from the dangers of lazy loading by disabling it in your Laravel app. You can also customise how violations are handled, which is perfect for models outside of your control e.g. within packages.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'You can replace Laravel''s stubs to customize files generated using artisan commands'
|
||||
tweet_id: '1489620183085768706'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: mattkingshott
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKbBGYpXIAACsW8.jpg'
|
||||
created_at: 2022-02-04T15:21:42+00:00
|
||||
slug: you-can-replace-laravels-stubs-to-customize-files-generated-using-artisan-commands
|
||||
---
|
||||
🔥 #Laravel Tip: If you find yourself constantly making changes to new files generated by Artisan's 'make' commands, then consider publishing the stubs and creating your own defaults. It can be a real time saver:
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'You can skip() TransformRequests-type middleware'
|
||||
tweet_id: '1494019554304880641'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: pascalbaljet
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKwygqPWQAMRaTr.jpg'
|
||||
created_at: 2022-02-16T18:43:13+00:00
|
||||
slug: you-can-skip-transformrequests-type-middleware
|
||||
---
|
||||
💡 As of @laravelphp v8.36.0, you can skip 'TransformRequests' middlewares by registering a callback.
|
||||
|
||||
For example, you can use it on 'TrimStrings' and 'ConvertEmptyStringsToNull'.
|
||||
|
||||
#Laravel #PHP #webdev
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 'You can swap multiple keywords in a string using this macro'
|
||||
tweet_id: '1489620174093176833'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: aarondfrancis
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKd_FZRXsAEgBjK.jpg'
|
||||
created_at: 2022-02-04T15:21:39+00:00
|
||||
slug: you-can-swap-multiple-keywords-in-a-string-using-this-macro
|
||||
---
|
||||
This is one of those macros I carry around from project to project.
|
||||
|
||||
Super clear, super easy, nice little life improvement.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'You can track logins and logouts for auditing purposes using Laravel''s native auth events'
|
||||
tweet_id: '1489620171241050112'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: mattkingshott
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKlsjn1WQAU_Xg2.jpg'
|
||||
created_at: 2022-02-04T15:21:39+00:00
|
||||
slug: you-can-track-logins-and-logouts-for-auditing-purposes-using-laravels-native-auth-events
|
||||
---
|
||||
🔥 #Laravel Tip: Tracking logins and logouts for auditing or security purposes is incredibly easy thanks to Laravel’s login and logout events. Simply listen for them in a service provider and respond when they are fired.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: 'You can use the @checked Blade directive to generate checked="" markup'
|
||||
tweet_id: '1494019560223096837'
|
||||
thread_slug: weekly-thread-2022-06
|
||||
author_username: AshAllenDesign
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKwA95pWUAInwgf.jpg'
|
||||
created_at: 2022-02-16T18:43:15+00:00
|
||||
slug: you-can-use-the-at-checked-blade-directive-to-generate-checked-markup
|
||||
---
|
||||
🔥 In Laravel 9, you'll be able to use the cool new "checked" Blade directive.
|
||||
|
||||
This is going to be a nice addition that we can use to clean up our Blade views a little bit
|
||||
|
||||
#laravel #php
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
title: 'You can use the getCollection() and setCollection() methods on the paginator to interact with the underlying data'
|
||||
tweet_id: '1489620186109857800'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: alanrezende
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKngV3LWQAQcft4.png'
|
||||
created_at: 2022-02-04T15:21:42+00:00
|
||||
slug: you-can-use-the-getcollection-and-setcollection-methods-on-the-paginator-to-interact-with-the-underlying-data
|
||||
---
|
||||
🔥 #Laravel paginator tip: you can use getCollection and setCollection if you need to do something to the paginator underlying data. Trust me you'll know when you need this.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 'You can use the new Str::transliterate() helper to convert a string to its closest ASCII representation'
|
||||
tweet_id: '1489620162357579778'
|
||||
thread_slug: weekly-thread-2022-05
|
||||
author_username: freekmurze
|
||||
images:
|
||||
- 'https://pbs.twimg.com/media/FKmRs46XsAA85Bh.jpg'
|
||||
created_at: 2022-02-04T15:21:37+00:00
|
||||
slug: you-can-use-the-new-strtransliterate-helper-to-convert-a-string-to-its-closest-ascii-representation
|
||||
---
|
||||
Pretty cool string helper method
|
||||
https://laravel-news.com/laravel-8-82-0
|
||||
#laravel #php
|
||||
13
content/tips/you-can-use-traits-inside-php-enums.md
Normal file
13
content/tips/you-can-use-traits-inside-php-enums.md
Normal 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 🔥
|
||||
|
|
@ -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:
|
||||
Loading…
Add table
Add a link
Reference in a new issue