1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 05:14:04 +00:00

Weekly thread #4 (#26)

* Use Author::updateOrCreate instead of firstOrCreate

* Weekly tips #4
This commit is contained in:
lukinovec 2022-01-28 18:03:12 +01:00 committed by GitHub
parent f1e283e142
commit e907eba3dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 140 additions and 4 deletions

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,