<?php
namespace App\Sports\Model;

use \System\Model;

/**
 * Class St_country
 * @package App\Sports\Model
 * 国家 地区 关系
 */
class St_area_country extends Model
{

    protected $table = 'st_area_country';

    //获取国家或地区 id
    public static function getID($opt = ''){
        $name = $opt;//国家或地区名称
        $ret = self::select('id','pid')
            ->where(['name'=>$name])
            ->first();

        if($ret->pid > 0){
            $data['area_id'] = $ret->pid;
            $data['country_id'] = $ret->id;
        }else{
            $data['area_id'] = $ret->id;
            $data['country_id'] = 0;
        }

        return $data;
    }
}