. */ namespace App\Sources; use App\Models\Author; use \App\Models\Game; use App\Models\Language; use App\Models\Platform; use \App\Source; /** * And here's the problem: there are no publication dates. */ class Dashingdon extends Source { public $title = "DashingDon"; public $keyword = 'dashingdon'; public function parse() { $platform = Platform::findByName('ChoiceScript'); $language = Language::findByCode('en'); $text = $this->get_text("https://dashingdon.com/"); $this->loadStr($text); unset($text); $this->dom->filter('#allgames > article > fieldset > div > section.col.col-8')->each(function($gameBlock) use($platform, $language) { $game = new Game(); $game->title = $gameBlock->filter('div.value-self > a')->text(); $game = $this->findGame($game); $game->url = $gameBlock->filter('div.value-self > a')->attr('href'); $game->url_play_online = $game->url; $game->description = trim($gameBlock->filter('.blurbbox')->text()); $author_name = $gameBlock->filter('p > strong')->first()->text(); $game->save(); $game->languages()->sync([$language->id]); $game->platforms()->sync([$platform->id]); $author = Author::findByName($author_name); if (!$author) { $author = new Author(); $author->name = $author_name; $author->save(); } $game->authors()->sync([$author->id]); }); } }