<?php

namespace App\Services\Pair;

use App\Models\Fpdx\PairModel;
use App\Services\Pair\DataModels\PairMatchDataSource;

class PairFirstMatch extends BasePairMatch
{
    public function __construct(int $stageId)
    {
        parent::__construct();
        $this->stageId = $stageId;
    }

    public function loadMatchData()
    {
        $datas = PairModel::where([
            array('stage_id', $this->stageId), array('state', '>', 100)
        ])->whereNull('assoc_id')->get()->sortByDesc('score')->toArray();

        $this->dataSources = array_map(function ($data) {
            return new PairMatchDataSource($data);
        }, $datas);
    }
}
