private function createHashtags($post, $twitterPost) { $hashtags = $twitterPost->entities->hashtags; foreach ($hashtags as $tag) { $tagText = htmlspecialchars($tag->text, ENT_QUOTES, 'UTF-8'); $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $tagText]); $posthashtagrelationship = \relive\models\PostHashtagRelationship::firstOrCreate(['post_id' => $post->post_id, 'hashtag_id' => $hashtag->hashtag_id]); } }
private function createHashtags($post, $content) { preg_match_all('/#([^\\s]+)/', $content, $matches); $hashtags = $matches[1]; foreach ($hashtags as $tag) { $tagText = htmlspecialchars($tag, ENT_QUOTES, 'UTF-8'); $hashtag = \relive\models\Hashtag::firstOrCreate(['hashtag' => $tagText]); $posthashtagrelationship = \relive\models\PostHashtagRelationship::firstOrCreate(['post_id' => $post->post_id, 'hashtag_id' => $hashtag->hashtag_id]); } }