Fix import for new pivot table
This commit is contained in:
parent
aa820303ec
commit
10afc3836a
@ -43,6 +43,7 @@ class ImportBookmark implements ShouldQueue
|
||||
$bookmark->updated_at = $created_at;
|
||||
$bookmark->save();
|
||||
|
||||
$tags = [];
|
||||
$tokens = explode(' ', $bookmark_json['tags']);
|
||||
foreach ($tokens as $tag_raw) {
|
||||
$tag = Tag::firstOrCreate(
|
||||
@ -50,12 +51,10 @@ class ImportBookmark implements ShouldQueue
|
||||
'name' => $tag_raw,
|
||||
]
|
||||
);
|
||||
|
||||
$bookmark_tag = new BookmarkTag;
|
||||
$bookmark_tag->bookmark_id = $bookmark->id;
|
||||
$bookmark_tag->tag_id = $tag->id;
|
||||
$bookmark_tag->save();
|
||||
$tags[$tag->id] = true;;
|
||||
}
|
||||
|
||||
$bookmark->tags()->sync(array_keys($tags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user