diff options
Diffstat (limited to 'app/Rugby/Factory')
-rw-r--r-- | app/Rugby/Factory/DataAdapter.php | 1 | ||||
-rw-r--r-- | app/Rugby/Factory/Service.php | 21 | ||||
-rw-r--r-- | app/Rugby/Factory/SixnationsrugbyAdapter.php | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/app/Rugby/Factory/DataAdapter.php b/app/Rugby/Factory/DataAdapter.php index b4971ce..d0434c9 100644 --- a/app/Rugby/Factory/DataAdapter.php +++ b/app/Rugby/Factory/DataAdapter.php @@ -4,5 +4,4 @@ namespace App\Rugby\Factory; interface DataAdapter { - } diff --git a/app/Rugby/Factory/Service.php b/app/Rugby/Factory/Service.php index fa8028f..e966ce6 100644 --- a/app/Rugby/Factory/Service.php +++ b/app/Rugby/Factory/Service.php @@ -52,6 +52,27 @@ class Service $away_team = Model\Team::Create(['name' => $data['team_away']]); } + $existing_match = Model\Match::whereHas( + 'teams', + function ($query) use ($home_team) { + $query->where('name', '=', $home_team->name); + } + )->whereHas( + 'teams', + function ($query) use ($away_team) { + $query->where('name', '=', $away_team->name); + } + )->whereHas( + 'tournaments', + function ($query) use ($tournament) { + $query->where('name', '=', $tournament->name); + } + )->get(); + + if ($existing_match->first()) { + return; + } + $match = Model\Match::create( [ 'date' => (new \Carbon\Carbon($data['match_date']))->format('Y-m-d H:i:s'), diff --git a/app/Rugby/Factory/SixnationsrugbyAdapter.php b/app/Rugby/Factory/SixnationsrugbyAdapter.php index 6b6edd7..4a36602 100644 --- a/app/Rugby/Factory/SixnationsrugbyAdapter.php +++ b/app/Rugby/Factory/SixnationsrugbyAdapter.php @@ -28,7 +28,6 @@ class SixnationsrugbyAdapter implements DataAdapter return $this->tournament_name; } - protected function cleanData($data) { // string |