belongsTo(ArticlesCategories::class, 'category_id'); } /** * Mutator method to set priceHt's value */ public function setContentRenderAttribute($value) { $this->contentRender = $value; } public function getContentRenderAttribute() { if (isset($this->contentRender)) { return $this->contentRender; } else { // youtube $content = preg_replace('/<\/oembed>/', '', $this->content); // vimeo $content = preg_replace('/<\/oembed>/', '', $content); // twitter // tweet oembed // match '/
<\/oembed><\/figure>/' // generate 'https://publish.twitter.com/oembed?url=https://twitter.com/${1} if (!App::environment("local")) { $tweets = preg_match_all('/
<\/oembed><\/figure>/', $content, $tweet_urls); foreach ($tweet_urls[1] as $onetweet) { $oembed = 'https://publish.twitter.com/oembed?url=https://twitter.com/' . $onetweet; $response = Http::get($oembed); $html_for_tweet = $response->json()['html']; $pattern = '/
<\/oembed><\/figure>/'; $content = preg_replace($pattern, $html_for_tweet, $content); } } else { $content = preg_replace('/
<\/oembed><\/figure>/', 'BEHIND PROXY RENDER : Tweet', $content); } // $this->contentRender = $content; return $this->contentRender = $content; }//end if } }