jingcai-php/app/Model/Lq/JclqMatch.php

67 lines
1.5 KiB
PHP
Executable File

<?php
/**
* @createtime 2023/4/26
* @author wild
* @copyright PhpStorm
*/
namespace App\Model\Lq;
use App\Model\BaseModel;
use App\Service\JingcaiLogoService;
use App\Utils\Helps;
class JclqMatch extends BaseModel
{
protected $appends = [
'start_week',
'start_time_str',
'competition_logo_url',
'home_team_logo_url',
'away_team_logo_url',
];
public function score()
{
return $this->belongsTo(JclqScore::class, 'match_id','match_id');
}
public function getCompetitionLogoUrlAttribute()
{
if (!$this->competition_id) {
return '';
}
return JingcaiLogoService::lqCompetition($this->competition_id);
}
public function getHomeTeamLogoUrlAttribute()
{
if (!$this->home_team_id) {
return '';
}
return JingcaiLogoService::lqTeam($this->home_team_id);
}
public function getAwayTeamLogoUrlAttribute()
{
if (!$this->competition_id) {
return '';
}
return JingcaiLogoService::lqTeam($this->away_team_id);
}
public function getStartWeekAttribute()
{
if (!$this->start_time) {
return '';
}
return Helps::getWeek($this->start_time);
}
public function getStartTimeStrAttribute()
{
if (!$this->start_time) {
return '';
}
return date('m-d H:i', strtotime($this->start_time));
}
}