href = $bookmark_json['href']; $bookmark->title = $bookmark_json['description']; $bookmark->description = $bookmark_json['extended']; $bookmark->created_at = $created_at; $bookmark->updated_at = $created_at; $bookmark->save(); $tokens = explode(' ', $bookmark_json['tags']); foreach ($tokens as $tag_raw) { $tag = Tag::firstOrCreate( [ 'name' => $tag_raw, ] ); $bookmark_tag = new BookmarkTag; $bookmark_tag->bookmark_id = $bookmark->id; $bookmark_tag->tag_id = $tag->id; $bookmark_tag->save(); } } DB::rollBack(); } }