| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Http\Model;
- use Illuminate\Database\Eloquent\Model;
- use App\Http\Response\Response;
- /**
- * Class Account
- * @package App\Sports\Model
- * 数据源球队model
- */
- class St_team extends Model
- {
- protected $table = 'st_team';
- public $timestamps = false;
- /**
- * 写入数据源球队数据
- * $game_code 球类代码
- * $team 球队名称
- * $source 数据来源
- */
- public static function setTeam($game_code,$teamNameArr=[],$source){
- if(!empty($game_code) and !empty($teamNameArr) and !empty($source)){
- //拼装数据
- foreach($teamNameArr as $k => $teamName){
- $set_arr[] = [
- 'game_type' => $game_code,
- 'team_name_cn' => $teamName,
- 'status' => 1,
- 'source' => $source,
- 'update_time' => date('Y-m-d H:i:s')
- ];
- }
- //循环写入/更新
- foreach($set_arr as $k =>$set){
- $ret = self::updateOrInsert(
- ['game_type' => $game_code, 'team_name_cn' => $set['team_name_cn'],'source'=>$set['source']],
- ['status' => $set['status'],'update_time' => $set['update_time']]
- );
- if(empty($ret)) return Response::generate('',Response::SET_TEAM_ERR);
- }
- }
- }
- }
|