<?php

namespace App\Models;
/**
 *
 */
class StoddsCode extends BaseModel
{
    protected $table = 'st_odds_code';
    public $timestamps = false;

    public function getTypeDatas($ret_game_code = '')
    {
        $all = self::all()->toArray();
        if (empty($all)) {
            return [];
        }

        $allIDKey = [];
        foreach ($all as $val) {
            $id = $val['id'];
            $allIDKey[$id] = $val;
        }

        $retall = [];
        foreach ($allIDKey as $id => $val) {
            if ($val['p_id'] != 0) {
                $game_code = $val['game_code'];
                $pid = $val['p_id'];
                $pidcode = $allIDKey[$pid]['odds_code'];
                $nowcode = $val['odds_code'];
                $retall[$game_code][$pidcode][$nowcode] = $val;
            }
        }
        if (empty($ret_game_code)) {
            return $retall;
        } else {
            return $retall[$ret_game_code];
        }
    }

}

?>