get(); $articlesitems = []; // Looping through the articles and scraping and while scraping it creates a new instance of the scraper. foreach ($articles as $article) { // Scrape the article $scrapedArticle = (new ThiladhunScraper)->extract($article["link"]); // Check if the scraped article is not null if ($scrapedArticle !== null && !empty($scrapedArticle)) { $articlesitems[] = $scrapedArticle; } } return $articlesitems; } }