67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Event extends Model
|
|
{
|
|
protected $fillable = [
|
|
'starttime',
|
|
'sport_id',
|
|
'country_id',
|
|
'group_id',
|
|
'competition_group_id',
|
|
'home_id',
|
|
'away_id',
|
|
'txodds_id',
|
|
'provider_id',
|
|
'betaid_id',
|
|
'betradar_id',
|
|
];
|
|
|
|
public function sport()
|
|
{
|
|
return $this->belongsTo(Sport::class);
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo(Country::class, 'country_id', 'txodds_id');
|
|
}
|
|
|
|
public function group()
|
|
{
|
|
return $this->hasOne(Group::class, 'txodds_id', 'group_id');
|
|
}
|
|
|
|
public function competition_group()
|
|
{
|
|
return $this->hasOne(CompetitionGroup::class, 'txodds_id', 'competition_group_id');
|
|
}
|
|
|
|
public function home()
|
|
{
|
|
return $this->hasOne(Element::class, 'txodds_id', 'home_id');
|
|
}
|
|
|
|
public function away()
|
|
{
|
|
return $this->hasOne(Element::class, 'txodds_id', 'away_id');
|
|
}
|
|
|
|
public function odds_3way()
|
|
{
|
|
$_bookmaker = Multiline::where('sport_id', auth()->user()->sport_id)
|
|
->where('client_id', auth()->user()->client_id)
|
|
->where('bettype_id', 1)
|
|
->where('matchpart_id', 1)
|
|
->pluck('bookmaker_id');
|
|
|
|
return $this->hasMany(Odds3way::class, 'event_id', 'id')
|
|
->join('multilines', 'multilines.bookmaker_id', 'odds_3ways.bookmaker_id')
|
|
->orderBy('multilines.sort');
|
|
// return $this->hasMany(Odds3way::class, 'event_id', 'id')->whereIn('bookmaker_id', $_bookmaker);
|
|
}
|
|
}
|