From d1fe4536cc039450b540104e382db0d01d5cf886 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Fri, 19 Jun 2020 02:16:51 +0100 Subject: Initial commit --- app/Console/Commands/ScrapeFiles.php | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 app/Console/Commands/ScrapeFiles.php (limited to 'app/Console/Commands/ScrapeFiles.php') diff --git a/app/Console/Commands/ScrapeFiles.php b/app/Console/Commands/ScrapeFiles.php new file mode 100644 index 0000000..05b7176 --- /dev/null +++ b/app/Console/Commands/ScrapeFiles.php @@ -0,0 +1,64 @@ +argument('directory'); + + if (!Storage::disk('local')->exists($directory)) { + $this->error('Could not load file at: ' . Storage::disk('local')->path($directory)); + return Command::FAILURE; + } + + $files = Storage::disk('local')->files($directory); + + + foreach ($files as $file) { + $tournament = 'Six Nations ' . explode('-', explode('.txt', $file)[0])[1]; + $raw_data = Storage::disk('local')->get($file); + + $service = new Service(new SixnationsrugbyAdapter($raw_data, $tournament)); + $service->save(); + } + + return Command::SUCCESS; + } + +} -- cgit v1.2.3