114 lines
2.9 KiB
PHP
Executable File
114 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Model\Zq;
|
|
|
|
use App\Enums\SaleState;
|
|
use App\Model\BaseModel;
|
|
use App\Model\Lottery;
|
|
use App\Utils\Helps;
|
|
use Illuminate\Support\Arr;
|
|
|
|
/**
|
|
* @protected $week_num
|
|
*/
|
|
class JczqOdds extends BaseModel
|
|
{
|
|
protected $casts = [
|
|
'spf_odds' => 'array',
|
|
'spf_odds_last' => 'array',
|
|
'rq_odds' => 'array',
|
|
'rq_odds_last' => 'array',
|
|
'bf_odds' => 'array',
|
|
'bf_odds_last' => 'array',
|
|
'jq_odds' => 'array',
|
|
'jq_odds_last' => 'array',
|
|
'bqc_odds' => 'array',
|
|
'bqc_odds_last' => 'array',
|
|
];
|
|
protected $appends = [
|
|
'issue_num_week',
|
|
'issue_num_day',
|
|
'play_num_view',
|
|
'week_num',
|
|
];
|
|
|
|
public function score() {
|
|
return $this->belongsTo(JczqScore::class, 'match_id', 'match_id');
|
|
}
|
|
|
|
public function match() {
|
|
return $this->belongsTo(ZqMatch::class, 'match_id', 'match_id');
|
|
}
|
|
|
|
public function getJcHomeTeamNameAttribute() {
|
|
if ($this->is_reverse == 1) {
|
|
return $this->attributes['jc_away_team_name'];
|
|
}
|
|
return $this->attributes['jc_home_team_name'];
|
|
}
|
|
public function getJcHomeTeamNameFullAttribute() {
|
|
|
|
if ($this->is_reverse == 1) {
|
|
return $this->attributes['jc_away_team_name_full'];
|
|
}
|
|
return $this->attributes['jc_home_team_name_full'];
|
|
}
|
|
|
|
public function getJcAwayTeamNameAttribute() {
|
|
if ($this->is_reverse == 1) {
|
|
return $this->attributes['jc_home_team_name'];
|
|
}
|
|
return $this->attributes['jc_away_team_name'];
|
|
}
|
|
public function getJcAwayTeamNameFullAttribute() {
|
|
if ($this->is_reverse == 1) {
|
|
return $this->attributes['jc_home_team_name_full'];
|
|
}
|
|
return $this->attributes['jc_away_team_name_full'];
|
|
}
|
|
|
|
|
|
public function getPlayNumViewAttribute() {
|
|
return sprintf('%03d', $this->play_num);
|
|
}
|
|
|
|
public function getWeekNumAttribute() {
|
|
$week = self::getIssueNumWeek($this->issue_num);
|
|
return Helps::weekStr2Num($week);
|
|
}
|
|
|
|
public function getIssueNumWeekAttribute() {
|
|
return self::getIssueNumWeek($this->issue_num);
|
|
}
|
|
public function getIssueNumDayAttribute()
|
|
{
|
|
return self::getIssueNumDay($this->issue_num);
|
|
}
|
|
|
|
public static function getIssueNumWeek($issueNum)
|
|
{
|
|
$arr = explode('/', $issueNum);
|
|
return Arr::get($arr, 1);
|
|
}
|
|
public static function getIssueNumDay($issueNum)
|
|
{
|
|
$arr = explode('/', $issueNum);
|
|
return Arr::get($arr, 0);
|
|
}
|
|
|
|
public function scopeSelling($query)
|
|
{
|
|
return $query->where('order_state', SaleState::Selling);
|
|
}
|
|
|
|
public function getCloseTime($earlySecond) {
|
|
$time = strtotime($this->real_close_time);
|
|
return date('Y-m-d H:i:s', $time - $earlySecond);
|
|
}
|
|
|
|
public function weekPlayFormat()
|
|
{
|
|
return sprintf('%s%03d', $this->week_num, $this->play_num);
|
|
}
|
|
}
|