Files
nuhodds_fi4/app/Models/Event.php
T
2026-08-21 13:38:58 +02:00

183 lines
3.9 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Support\Facades\Auth;
class Event extends Model
{
use Prunable;
protected $fillable = [
'id',
'has_markets',
'provider_id',
'betsapi_id',
'betradar_id',
'bet365_id',
'_1xbet_id',
'bwin_id',
'magnig_id',
'magken_id',
'lognig_id',
'logcol_id',
'starttime',
'sport_id',
'country_id',
'group_id',
'competition_group_id',
'home_id',
'away_id',
];
/**
* Get the prunable model query.
*/
public function prunable()
{
return static::where('starttime', '<', now()->subHours(5));
}
public function provider()
{
return $this->belongsTo(Provider::class);
}
public function sport()
{
return $this->belongsTo(Sport::class)->where('is_active', 1);
}
public function country()
{
return $this->belongsTo(Country::class)->where('disabled', 0);
}
public function group()
{
return $this->belongsTo(Group::class);
}
public function competition_group()
{
return $this->belongsTo(CompetitionGroup::class);
}
public function home()
{
return $this->belongsTo(Element::class);
}
public function away()
{
return $this->belongsTo(Element::class);
}
public function home_betsapi()
{
return $this->belongsTo(ElementProvider::class, 'home_id', 'element_id')->where('provider_id', 2);
}
public function away_betsapi()
{
return $this->belongsTo(ElementProvider::class, 'away_id', 'element_id')->where('provider_id', 2);
}
public function odds_2ways()
{
return $this->hasMany(Odds2way::class);
}
public function odds_2ways_s1()
{
return $this->hasMany(Odds2wayS1::class);
}
public function odds_3ways()
{
return $this->hasMany(Odds3way::class);
}
public function odds_3ways_bf()
{
return $this->hasMany(Odds3way::class)->where('bookmaker_id', 110);
}
public function odds_3ways_ht()
{
return $this->hasMany(Odds3wayHt::class);
}
public function odds_dc()
{
return $this->hasMany(OddsDc::class);
}
public function odds_dnb()
{
return $this->hasMany(OddsDnb::class);
}
public function odds_ggng()
{
return $this->hasMany(OddsGgng::class);
}
public function odds_points()
{
return $this->hasMany(OddsPoint::class)->where('active_spread', 1);
}
public function odds_points_q1()
{
return $this->hasMany(OddsPointQ1::class)->where('active_spread', 1);
}
public function odds_points_ht()
{
return $this->hasMany(OddsPointHt::class)->where('active_spread', 1);
}
public function odds_totals()
{
return $this->hasMany(OddsTotal::class)->where('active_spread', 1);
}
public function odds_totals_bf()
{
return $this->hasMany(OddsTotal::class)->where('bookmaker_id', 110);
}
public function odds_totals_q1()
{
return $this->hasMany(OddsTotalQ1::class)->where('active_spread', 1);
}
public function odds_totals_ht()
{
return $this->hasMany(OddsTotalHt::class)->where('active_spread', 1);
}
public function odds_tq()
{
return $this->hasMany(OddsTq::class);
}
public function event_user_star()
{
return $this->hasOne(EventUserStar::class, 'event_id', 'id');
}
public function event_user_note()
{
return $this->hasMany(EventUserNote::class, 'event_id', 'id');
}
public function event_bookmaker()
{
return $this->hasOne(EventBookmaker::class, 'event_id', 'id')->where('bookmaker_id', Auth::user()->bookmaker_id);
}
}