1
0
Fork 0

Merge pull request #3122 from idanoo/hashtag_unique_constraint_fix

Fix for firstOrCreate failing hashtags with case differences on name column
This commit is contained in:
daniel 2022-01-05 18:44:32 -07:00 committed by GitHub
commit 3ee699ba3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -107,9 +107,13 @@ class StatusEntityLexer implements ShouldQueue
}
DB::transaction(function () use ($status, $tag) {
$slug = str_slug($tag, '-', false);
$hashtag = Hashtag::firstOrCreate(
['name' => $tag, 'slug' => $slug]
);
$hashtag = Hashtag::where('slug', $slug)->first();
if (!$hashtag) {
$hashtag = Hashtag::create(
['name' => $tag, 'slug' => $slug]
);
}
StatusHashtag::firstOrCreate(
[
'status_id' => $status->id,