diff --git a/app/Models/Tip.php b/app/Models/Tip.php index 4180f46..3321f6d 100644 --- a/app/Models/Tip.php +++ b/app/Models/Tip.php @@ -75,7 +75,7 @@ class Tip extends Model 'content' => (string) Str::of($tweet->text)->explode("\n")->skip(1)->join("\n"), 'tweet_id' => $tweet->id, 'thread_slug' => $threadSlug ?? optional(Thread::firstWhere('tweet_id', $tweet->threadId))->slug, - 'author_username' => Author::firstOrCreate([ + 'author_username' => Author::updateOrCreate(['username' => $tweet->author->username], [ 'username' => $tweet->author->username, 'name' => $tweet->author->name, 'avatar' => $tweet->author->profile_image_url, diff --git a/content/authors/alexjgarrett.md b/content/authors/alexjgarrett.md index a2a040d..0ad88e1 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' name: 'Alex Garrett-Smith' -avatar: 'https://pbs.twimg.com/profile_images/860958772671500289/63kCnhYX_normal.jpg' --- diff --git a/content/authors/austencam.md b/content/authors/austencam.md new file mode 100644 index 0000000..c59dc10 --- /dev/null +++ b/content/authors/austencam.md @@ -0,0 +1,5 @@ +--- +username: austencam +name: 'Austen Cameron' +avatar: 'https://pbs.twimg.com/profile_images/1398382260542390279/83-mTSq1_normal.jpg' +--- diff --git a/content/authors/bhaidar.md b/content/authors/bhaidar.md index 03cc899..16718ba 100644 --- a/content/authors/bhaidar.md +++ b/content/authors/bhaidar.md @@ -1,5 +1,5 @@ --- username: bhaidar -name: 'Bilal Haidar . Laravel Enthusiast' avatar: 'https://pbs.twimg.com/profile_images/1381347341400215552/LvVOFV9__normal.jpg' +name: 'Bilal Haidar | Laravel Enthusiast' --- diff --git a/content/authors/cerbero90.md b/content/authors/cerbero90.md new file mode 100644 index 0000000..f1b6c8e --- /dev/null +++ b/content/authors/cerbero90.md @@ -0,0 +1,5 @@ +--- +username: cerbero90 +name: 'Andrea Marco Sartori' +avatar: 'https://pbs.twimg.com/profile_images/956500408377139200/QkHAZFZ9_normal.jpg' +--- diff --git a/content/authors/tobias_petry.md b/content/authors/tobias_petry.md index 3f04885..f67583b 100644 --- a/content/authors/tobias_petry.md +++ b/content/authors/tobias_petry.md @@ -1,5 +1,5 @@ --- username: tobias_petry -name: 'Tobias Petry' avatar: 'https://pbs.twimg.com/profile_images/1449987893980766209/iPIfnmTE_normal.jpg' +name: Tobias_Petry.sql --- diff --git a/content/threads/weekly-thread-2022-04.md b/content/threads/weekly-thread-2022-04.md new file mode 100644 index 0000000..89704ea --- /dev/null +++ b/content/threads/weekly-thread-2022-04.md @@ -0,0 +1,11 @@ +--- +slug: weekly-thread-2022-04 +title: 'Weekly thread #04 of 2022' +tweet_id: '1487081923289640961' +author_username: archtechx +created_at: 2022-01-28T16:33:49+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/convert-email-addresses-to-full-names-with-the-help-of-strheadline.md b/content/tips/convert-email-addresses-to-full-names-with-the-help-of-strheadline.md new file mode 100644 index 0000000..44a86b1 --- /dev/null +++ b/content/tips/convert-email-addresses-to-full-names-with-the-help-of-strheadline.md @@ -0,0 +1,11 @@ +--- +title: 'Convert email addresses to full names with the help of Str::headline()' +tweet_id: '1487081950900736012' +thread_slug: weekly-thread-2022-04 +author_username: SteveTheBauman +images: + - 'https://pbs.twimg.com/media/FKDXqE8XoAU5xO8.jpg' +created_at: 2022-01-28T15:15:40+00:00 +slug: convert-email-addresses-to-full-names-with-the-help-of-strheadline +--- +Ran into a great use-case for Str::headline() -- Generating displayable usernames from email addresses 👌 \ No newline at end of file diff --git a/content/tips/higher-order-messages-are-a-great-way-to-tidy-up-long-collection-logic.md b/content/tips/higher-order-messages-are-a-great-way-to-tidy-up-long-collection-logic.md new file mode 100644 index 0000000..d82acc4 --- /dev/null +++ b/content/tips/higher-order-messages-are-a-great-way-to-tidy-up-long-collection-logic.md @@ -0,0 +1,13 @@ +--- +title: 'Higher-order messages are a great way to tidy up long collection logic' +tweet_id: '1487081947864002572' +thread_slug: weekly-thread-2022-04 +author_username: alexjgarrett +images: + - 'https://pbs.twimg.com/media/FKD7ajmXIAAEjTW.jpg' +created_at: 2022-01-28T15:15:39+00:00 +slug: higher-order-messages-are-a-great-way-to-tidy-up-long-collection-logic +--- +Sometimes I forget about higher order collection messages in Laravel, but they're a great way to shorten and tidy up your code ✨ + +Here's a simplified (and not recommended) example. \ No newline at end of file diff --git a/content/tips/laravels-container-can-be-used-for-resolving-variadic-dependencies.md b/content/tips/laravels-container-can-be-used-for-resolving-variadic-dependencies.md new file mode 100644 index 0000000..45795be --- /dev/null +++ b/content/tips/laravels-container-can-be-used-for-resolving-variadic-dependencies.md @@ -0,0 +1,15 @@ +--- +title: 'Laravel''s container can be used for resolving variadic dependencies' +tweet_id: '1487081929123897344' +thread_slug: weekly-thread-2022-04 +author_username: cerbero90 +images: + - 'https://pbs.twimg.com/media/FJ7_971aUAoMZF5.png' +created_at: 2022-01-28T15:15:35+00:00 +slug: laravels-container-can-be-used-for-resolving-variadic-dependencies +--- +Since @laravelphp 8.79 it is possible to resolve variadic dependencies out of the IoC container. + +This is quite useful for type-hinting and static analysis and allows us to bind a set of concrete implementations to an abstraction layer. + +#Laravel #PHP \ No newline at end of file diff --git a/content/tips/the-value-helper-returns-the-passed-value-unless-its-invokable-then-it-first-calls-it.md b/content/tips/the-value-helper-returns-the-passed-value-unless-its-invokable-then-it-first-calls-it.md new file mode 100644 index 0000000..30caf62 --- /dev/null +++ b/content/tips/the-value-helper-returns-the-passed-value-unless-its-invokable-then-it-first-calls-it.md @@ -0,0 +1,11 @@ +--- +title: 'The value() helper returns the passed value UNLESS it''s invokable — then it first calls it' +tweet_id: '1487081938623995912' +thread_slug: weekly-thread-2022-04 +author_username: marcelpociot +images: + - 'https://pbs.twimg.com/media/FJ-5q6EWQAMKjpX.jpg' +created_at: 2022-01-28T15:15:37+00:00 +slug: the-value-helper-returns-the-passed-value-unless-its-invokable-then-it-first-calls-it +--- +I absolutely love the little "value" helper method in @laravelphp as it allows you to create beautiful APIs with ease under the hood. \ No newline at end of file diff --git a/content/tips/use-eloquent-scopes-to-clean-up-complex-relation-queries.md b/content/tips/use-eloquent-scopes-to-clean-up-complex-relation-queries.md new file mode 100644 index 0000000..8bd2c90 --- /dev/null +++ b/content/tips/use-eloquent-scopes-to-clean-up-complex-relation-queries.md @@ -0,0 +1,13 @@ +--- +title: 'Use Eloquent scopes to clean up complex relation queries' +tweet_id: '1487081935478276103' +thread_slug: weekly-thread-2022-04 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FKCIrumVQAcD8RB.jpg' +created_at: 2022-01-28T15:15:36+00:00 +slug: use-eloquent-scopes-to-clean-up-complex-relation-queries +--- +🔥 Eloquent scopes pair very well with complex relation queries + +Scopes should also have @method annotations. They make the model more self-documenting & better supported in IDEs \ No newline at end of file diff --git a/content/tips/use-postgresqls-trigram-indexes-to-make-where-like-queries-faster.md b/content/tips/use-postgresqls-trigram-indexes-to-make-where-like-queries-faster.md new file mode 100644 index 0000000..33fe744 --- /dev/null +++ b/content/tips/use-postgresqls-trigram-indexes-to-make-where-like-queries-faster.md @@ -0,0 +1,13 @@ +--- +title: 'Use PostgreSQL''s trigram indexes to make WHERE LIKE queries faster' +tweet_id: '1487081932202463236' +thread_slug: weekly-thread-2022-04 +author_username: tobias_petry +images: + - 'https://pbs.twimg.com/media/FKB7gJiWQAwc5QS.jpg' +created_at: 2022-01-28T15:15:35+00:00 +slug: use-postgresqls-trigram-indexes-to-make-where-like-queries-faster +--- +⚡️ Database Tip + +Every database performance guide is repeating the false statement stating WHERE LIKE '%search%' queries can't use an index. That is just not true! Most probably your database can't, but PostgreSQL implements trigram indexes which will make this really fast! \ No newline at end of file diff --git a/content/tips/use-tailwinds-color-opacity-modifier-to-change-the-background-color-and-opacity-in-a-single-class.md b/content/tips/use-tailwinds-color-opacity-modifier-to-change-the-background-color-and-opacity-in-a-single-class.md new file mode 100644 index 0000000..aa92249 --- /dev/null +++ b/content/tips/use-tailwinds-color-opacity-modifier-to-change-the-background-color-and-opacity-in-a-single-class.md @@ -0,0 +1,13 @@ +--- +title: 'Use Tailwind''s color opacity modifier to change the background color and opacity in a single class' +tweet_id: '1487081941711028227' +thread_slug: weekly-thread-2022-04 +author_username: austencam +images: + - 'https://pbs.twimg.com/media/FKJYn3PUYAEecqU.jpg' +created_at: 2022-01-28T15:15:38+00:00 +slug: use-tailwinds-color-opacity-modifier-to-change-the-background-color-and-opacity-in-a-single-class +--- +✨Did you know Tailwind CSS has a shorthand syntax for background, border, and text opacity? + +🔗 https://tailwindcss.com/docs/background-color#changing-the-opacity \ No newline at end of file diff --git a/content/tips/you-can-use-the-date-helper-on-the-request-class-to-retrieve-a-value-as-a-carbon-instance.md b/content/tips/you-can-use-the-date-helper-on-the-request-class-to-retrieve-a-value-as-a-carbon-instance.md new file mode 100644 index 0000000..03d996b --- /dev/null +++ b/content/tips/you-can-use-the-date-helper-on-the-request-class-to-retrieve-a-value-as-a-carbon-instance.md @@ -0,0 +1,13 @@ +--- +title: 'You can use the date helper on the Request class to retrieve a value as a Carbon instance' +tweet_id: '1487081926103945217' +thread_slug: weekly-thread-2022-04 +author_username: mmartin_joo +images: + - 'https://pbs.twimg.com/media/FJ49UFhWYAEWFyu.jpg' +created_at: 2022-01-28T15:15:34+00:00 +slug: you-can-use-the-date-helper-on-the-request-class-to-retrieve-a-value-as-a-carbon-instance +--- +💡There's a really helpful date helper on the Request class. + +You can retrieve a value as a Carbon instance: \ No newline at end of file diff --git a/content/tips/you-can-use-usecurrent-usecurrentonupdate-on-timestamp-fields-in-your-migrations.md b/content/tips/you-can-use-usecurrent-usecurrentonupdate-on-timestamp-fields-in-your-migrations.md new file mode 100644 index 0000000..721ef41 --- /dev/null +++ b/content/tips/you-can-use-usecurrent-usecurrentonupdate-on-timestamp-fields-in-your-migrations.md @@ -0,0 +1,13 @@ +--- +title: 'You can use useCurrent() & useCurrentOnUpdate() on timestamp fields in your migrations' +tweet_id: '1487081944777035777' +thread_slug: weekly-thread-2022-04 +author_username: bhaidar +images: + - 'https://pbs.twimg.com/media/FJX3Lg1VUAEvcQH.jpg' +created_at: 2022-01-28T15:15:38+00:00 +slug: you-can-use-usecurrent-usecurrentonupdate-on-timestamp-fields-in-your-migrations +--- +🌶️ #Laravel tip: When using timestamp() columns in Laravel Migrations, append the useCurrent() & useCurrentOnUpdate() to set timestamp columns' default value to CURRENT_TIMESTAMP + +#PHP #Developers