Files
nuhodds_fi4/app/Models/StatisticFixtures.php
T
2026-10-04 15:25:03 +02:00

58 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Support\Carbon;
class StatisticFixtures extends Model
{
use Prunable;
protected $fillable = [
'sport_id',
'league_id',
'home_id',
'away_id',
'starttime',
'exp_home',
'exp_away',
];
protected function casts(): array
{
return [
'starttime' => 'datetime',
];
}
/**
* Get the prunable model query.
*/
public function prunable()
{
return static::where('starttime', '<', Carbon::now('Europe/Vienna')->subMinutes(5));
}
public function sport()
{
return $this->belongsTo(Sport::class)->where('is_active', 1);
}
public function league()
{
return $this->belongsTo(SofaScoreTournament::class, 'league_id', 'tournament_id');
}
public function home()
{
return $this->belongsTo(SofaScoreRosa::class, 'home_id', 'ss_team_id');
}
public function away()
{
return $this->belongsTo(SofaScoreRosa::class, 'away_id', 'ss_team_id');
}
}