multilines wip

This commit is contained in:
salam committed 2025-12-13 09:57:15 +01:00
1 parent 218c1e6e1c
commit 825a8d430c
19 files changed
+145 -78

No files matched your search

+1 -10
View File
@@ -52,15 +52,6 @@ class Event extends Model
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);
return $this->hasMany(Odds3way::class, 'event_id', 'id')->with('bookmaker');
}
}
+6
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Scopes\ClientScope;
use Illuminate\Database\Eloquent\Model;
class Multiline extends Model
@@ -34,4 +35,9 @@ class Multiline extends Model
{
return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid');
}
protected static function booted(): void
{
static::addGlobalScope(new ClientScope);
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Models\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
class ClientScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*/
public function apply(Builder $builder, Model $model): void
{
if (auth()->hasUser()) {
$builder->where('client_id', auth()->user()->client_id);
}
}
}