1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00

Use Author::updateOrCreate instead of firstOrCreate

This commit is contained in:
lukinovec 2022-01-28 17:36:32 +01:00
parent f1e283e142
commit 72fff055f4

View file

@ -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,