jingcai-php/app/Model/Zq/CtzqJqc.php

55 lines
1.0 KiB
PHP
Executable File

<?php
/**
* @createtime 2023/4/26
* @author wild
* @copyright PhpStorm
*/
namespace App\Model\Zq;
use App\Model\BaseModel;
class CtzqJqc extends BaseModel
{
protected $appends = [
'result_array',
];
protected $casts = [
'matchs' => 'array',
];
public function matches() {
return $this->hasMany(CtzqJqcMatch::class, 'ctzq_jqc_id', 'id');
}
public function getResultArrayAttribute() {
if (!$this->result_info) {
return [];
}
$result = [];
$len = strlen($this->result_info);
for($i=0;$i<$len;$i++) {
$val = $this->result_info[$i];
if ($val == '+') {
continue;
}
$item = $val;
if ($val == '3') {
$item = '3+';
}
$result[] = $item;
}
return $result;
}
public function getCloseTime($earlySecond) {
$time = strtotime($this->end_time);
return date('Y-m-d H:i:s', $time - $earlySecond);
}
}