diff --git a/content/threads/weekly-thread-2022-17.md b/content/threads/weekly-thread-2022-17.md new file mode 100644 index 0000000..2be4bf3 --- /dev/null +++ b/content/threads/weekly-thread-2022-17.md @@ -0,0 +1,11 @@ +--- +slug: weekly-thread-2022-17 +title: 'Weekly thread #17 of 2022' +tweet_id: '1520040279092326405' +author_username: archtechx +created_at: 2022-04-29T14:00:18+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/you-can-define-default-model-data-for-belongsto-relationships.md b/content/tips/you-can-define-default-model-data-for-belongsto-relationships.md new file mode 100644 index 0000000..8ddaa67 --- /dev/null +++ b/content/tips/you-can-define-default-model-data-for-belongsto-relationships.md @@ -0,0 +1,15 @@ +--- +title: 'You can define default model data for BelongsTo relationships' +tweet_id: '1520040284783972352' +thread_slug: weekly-thread-2022-17 +author_username: cosmeescobedo +images: + - 'https://pbs.twimg.com/media/FQ6XRnBVgAAHT1w.jpg' +created_at: 2022-04-29T14:00:19+00:00 +slug: you-can-define-default-model-data-for-belongsto-relationships +--- +๐Ÿ”ฅ Laravel Tip: Default Models. + +In your relationships, you can define default models. + +That way if the relationship doesn't exist it will return a default model so you don't have to check if is null every time. \ No newline at end of file diff --git a/content/tips/you-can-dynamically-create-and-extend-interfaces-in-php.md b/content/tips/you-can-dynamically-create-and-extend-interfaces-in-php.md new file mode 100644 index 0000000..f8bca51 --- /dev/null +++ b/content/tips/you-can-dynamically-create-and-extend-interfaces-in-php.md @@ -0,0 +1,13 @@ +--- +title: 'You can dynamically create and extend interfaces in PHP' +tweet_id: '1520040287719944192' +thread_slug: weekly-thread-2022-17 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FRLy5UXWYAIRIet.jpg' +created_at: 2022-04-29T14:00:20+00:00 +slug: you-can-dynamically-create-and-extend-interfaces-in-php +--- +๐Ÿ”ฅ Did you know you can dynamically create and/or extend interfaces in #PHP? + +Example from the @pestphp codebase: https://github.com/pestphp/pest/blob/1.x/src/Contracts/HasPrintableTestCaseName.php \ No newline at end of file diff --git a/content/tips/you-can-make-concurrent-requests-using-the-http-clients-pool-method.md b/content/tips/you-can-make-concurrent-requests-using-the-http-clients-pool-method.md new file mode 100644 index 0000000..5c81f19 --- /dev/null +++ b/content/tips/you-can-make-concurrent-requests-using-the-http-clients-pool-method.md @@ -0,0 +1,13 @@ +--- +title: 'You can make concurrent requests using the Http client''s `pool() method' +tweet_id: '1520040293952675840' +thread_slug: weekly-thread-2022-17 +author_username: cosmeescobedo +images: + - 'https://pbs.twimg.com/media/FQ6aAz0VgAARieH.jpg' +created_at: 2022-04-29T14:00:21+00:00 +slug: you-can-make-concurrent-requests-using-the-http-clients-pool-method +--- +๐Ÿ”ฅ Laravel Tip: Concurrent Requests. + +Using the HTTP client you can make concurrent requests using the pool method. \ No newline at end of file diff --git a/content/tips/you-can-use-eloquents-exists-method-to-check-whether-a-record-exists.md b/content/tips/you-can-use-eloquents-exists-method-to-check-whether-a-record-exists.md new file mode 100644 index 0000000..ddafb31 --- /dev/null +++ b/content/tips/you-can-use-eloquents-exists-method-to-check-whether-a-record-exists.md @@ -0,0 +1,11 @@ +--- +title: 'You can use Eloquent''s `exists()` method to check whether a record exists' +tweet_id: '1520040290911879168' +thread_slug: weekly-thread-2022-17 +author_username: ecrmnn +images: + - 'https://pbs.twimg.com/media/FRXTNRNWUAA7JtE.jpg' +created_at: 2022-04-29T14:00:20+00:00 +slug: you-can-use-eloquents-exists-method-to-check-whether-a-record-exists +--- +This is old, but still a great feature. Eloquent is so smooth! Check if a record exists in Laravel with exists() and doesNotExists() \ No newline at end of file diff --git a/content/tips/you-can-validate-a-field-and-exclude-it-from-the-validated-data.md b/content/tips/you-can-validate-a-field-and-exclude-it-from-the-validated-data.md new file mode 100644 index 0000000..2cdc339 --- /dev/null +++ b/content/tips/you-can-validate-a-field-and-exclude-it-from-the-validated-data.md @@ -0,0 +1,11 @@ +--- +title: 'You can validate a field and exclude it from the validated() data' +tweet_id: '1520040281818550274' +thread_slug: weekly-thread-2022-17 +author_username: mattkingshott +images: + - 'https://pbs.twimg.com/media/FRLzG4QXEAAOfyA.jpg' +created_at: 2022-04-29T14:00:18+00:00 +slug: you-can-validate-a-field-and-exclude-it-from-the-validated-data +--- +๐Ÿ”ฅ #Laravel Tip: When you need to validate a field, but don't actually require it for anything e.g. 'accept terms and conditions', make use of the 'exclude' rule. That way, the 'validated' method won't return it... \ No newline at end of file diff --git a/content/tips/you-can-validate-json-columns-at-the-database-level.md b/content/tips/you-can-validate-json-columns-at-the-database-level.md new file mode 100644 index 0000000..c65c155 --- /dev/null +++ b/content/tips/you-can-validate-json-columns-at-the-database-level.md @@ -0,0 +1,15 @@ +--- +title: 'You can validate JSON columns at the database level' +tweet_id: '1520040296930705408' +thread_slug: weekly-thread-2022-17 +author_username: tobias_petry +images: + - 'https://pbs.twimg.com/media/FRQ0DmDXsAE_gbI.jpg' +created_at: 2022-04-29T14:00:22+00:00 +slug: you-can-validate-json-columns-at-the-database-level +--- +โšก๏ธ Database Tip + +Extending a traditional database schema with NoSQL-like JSON columns can make the schema more understandable. But you should also ensure these JSON documents conform to an expected schema! + +https://sqlfordevs.io/tips/json-schema-validation \ No newline at end of file