156 lines
3.2 KiB
PHP
156 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Scopes\SportScope;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Event extends Model
|
|
{
|
|
protected $fillable = [
|
|
'id',
|
|
'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',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::addGlobalScope(new SportScope);
|
|
}
|
|
|
|
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)->where('is_country', 1);
|
|
}
|
|
|
|
public function group()
|
|
{
|
|
return $this->belongsTo(Group::class);
|
|
}
|
|
|
|
public function user_notes()
|
|
{
|
|
return $this->hasMany(UserNote::class, 'event_id', 'id');
|
|
}
|
|
|
|
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 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_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_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_bookmaker()
|
|
{
|
|
return $this->hasOne(EventBookmaker::class, 'event_id', 'id')->where('bookmaker_id', auth()->user()->bookmaker_id);
|
|
}
|
|
}
|