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->updated_at = $created_at;
|
||||||
$bookmark->save();
|
$bookmark->save();
|
||||||
|
|
||||||
|
$tags = [];
|
||||||
$tokens = explode(' ', $bookmark_json['tags']);
|
$tokens = explode(' ', $bookmark_json['tags']);
|
||||||
foreach ($tokens as $tag_raw) {
|
foreach ($tokens as $tag_raw) {
|
||||||
$tag = Tag::firstOrCreate(
|
$tag = Tag::firstOrCreate(
|
||||||
@ -50,12 +51,10 @@ class ImportBookmark implements ShouldQueue
|
|||||||
'name' => $tag_raw,
|
'name' => $tag_raw,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
$tags[$tag->id] = true;;
|
||||||
$bookmark_tag = new BookmarkTag;
|
|
||||||
$bookmark_tag->bookmark_id = $bookmark->id;
|
|
||||||
$bookmark_tag->tag_id = $tag->id;
|
|
||||||
$bookmark_tag->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bookmark->tags()->sync(array_keys($tags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user