comparatore bookmaker odds wip
This commit is contained in:
1 parent
adaec7b3dc
commit
218c1e6e1c
59 files changed
+470
-129
No files matched your search
@@ -8,5 +8,5 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class SettingsCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2;
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::AdjustmentsHorizontal;
|
||||
}
|
||||
@@ -23,13 +23,10 @@ class BettypeResource extends Resource
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
|
||||
protected static ?string $navigationLabel = 'Bettype';
|
||||
|
||||
protected static ?string $modelLabel = 'Bettype';
|
||||
|
||||
protected static ?string $title = 'Bettype';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Bettypes';
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return auth()->user()->super_admin == 1;
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Resources\Events\Pages\ListEvents;
|
||||
use App\Filament\Resources\Events\Schemas\EventForm;
|
||||
use App\Filament\Resources\Events\Tables\EventsTable;
|
||||
use App\Models\Event;
|
||||
use App\Models\Multiline;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -57,14 +58,24 @@ class EventResource extends Resource
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->withoutGlobalScopes()->where('starttime', '>', Carbon::now())->count();
|
||||
return parent::getEloquentQuery()
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->count();
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
// $_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')
|
||||
// ->toArray();
|
||||
|
||||
return parent::getEloquentQuery()
|
||||
// ->join('odds_3ways', 'odds_3ways.event_id', '=', 'events.id')
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->withoutGlobalScopes()->with('odds_3way');
|
||||
->where('sport_id', auth()->user()->sport_id);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class EventsTable
|
||||
->width('1rem')
|
||||
->size(IconSize::ExtraLarge)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->txodds_id),
|
||||
->tooltip(fn ($record) => $record->id),
|
||||
TextColumn::make('txodds_id')->searchable()->label('Match Id')->badge()->copyable(),
|
||||
TextColumn::make('starttime')
|
||||
->label('Start')
|
||||
@@ -41,7 +41,8 @@ class EventsTable
|
||||
->description(fn ($record) => $record->competition_group->name),
|
||||
TextColumn::make('home.name')->alignRight()->searchable(),
|
||||
TextColumn::make('away.name')->searchable(),
|
||||
Odds3Way::make('3way')->label('1 X 2')->alignCenter(),
|
||||
|
||||
Odds3Way::make('odds_3way')->label('Market 1X2'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines;
|
||||
|
||||
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||
use App\Filament\Resources\Multilines\Pages\ListMultilines;
|
||||
use App\Filament\Resources\Multilines\Schemas\MultilineForm;
|
||||
use App\Filament\Resources\Multilines\Tables\MultilinesTable;
|
||||
use App\Models\Multiline;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MultilineResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Multiline::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Bars3;
|
||||
|
||||
protected static ?string $cluster = SettingsCluster::class;
|
||||
|
||||
// protected static string|\UnitEnum|null $navigationGroup = 'Settings';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return MultilineForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return MultilinesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListMultilines::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines\Pages;
|
||||
|
||||
use App\Filament\Resources\Multilines\MultilineResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMultiline extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MultilineResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines\Pages;
|
||||
|
||||
use App\Filament\Resources\Multilines\MultilineResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMultiline extends EditRecord
|
||||
{
|
||||
protected static string $resource = MultilineResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines\Pages;
|
||||
|
||||
use App\Filament\Resources\Multilines\MultilineResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMultilines extends ListRecords
|
||||
{
|
||||
protected static string $resource = MultilineResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->createAnother(false)
|
||||
->hidden(! auth()->user()->super_admin),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines\Schemas;
|
||||
|
||||
use App\Models\Bettype;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Matchpart;
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class MultilineForm
|
||||
{
|
||||
public static $bettypes = [1, 2, 3, 4, 16, 2001, 2002, 2021, 3001, 3002, 3021];
|
||||
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('sport_id')
|
||||
->live()
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id'))
|
||||
->preload(),
|
||||
Select::make('matchpart_id')
|
||||
->options(Matchpart::where('is_active', 1)->pluck('name', 'id'))
|
||||
->preload(),
|
||||
Select::make('bettype_id')
|
||||
->options(fn (Get $get) => Bettype::where('sport_id', $get('sport_id'))->whereIn('bettype_id', self::$bettypes)->pluck('name', 'bettype_id')),
|
||||
Select::make('bookmaker_id')
|
||||
->options(Bookmaker::where('is_active', 1)->pluck('name', 'txid'))
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Multilines\Tables;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MultilinesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->reorderRecordsTriggerAction(
|
||||
fn (Action $action, bool $isReordering) => $action
|
||||
->button()
|
||||
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
|
||||
)
|
||||
->reorderable('sort')
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->width('1rem')
|
||||
->icon(function ($record): string {
|
||||
return $record->sport->icon;
|
||||
}),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('matchpart.name'),
|
||||
TextColumn::make('bettype.name'),
|
||||
TextColumn::make('bookmaker.name'),
|
||||
BookmakerIcon::make('bookmaker.icon')->label('Icon'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
->mutateDataUsing(function (array $data): array {
|
||||
$data['client_id'] = auth()->user()->client_id;
|
||||
|
||||
return $data;
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class BookmakerIcon extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.bookmaker-icon';
|
||||
}
|
||||
@@ -10,4 +10,9 @@ class Bettype extends Model
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function matchpart()
|
||||
{
|
||||
return $this->belongsTo(Matchpart::class);
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -52,6 +52,15 @@ class Event extends Model
|
||||
|
||||
public function odds_3way()
|
||||
{
|
||||
return $this->hasMany(Odds3way::class);
|
||||
$_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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Matchpart extends Model {}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Multiline extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'client_id',
|
||||
'sport_id',
|
||||
'bettype_id',
|
||||
'matchpart_id',
|
||||
'bookmaker_id',
|
||||
'sort',
|
||||
];
|
||||
|
||||
public function sport()
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function matchpart()
|
||||
{
|
||||
return $this->belongsTo(Matchpart::class);
|
||||
}
|
||||
|
||||
public function bettype()
|
||||
{
|
||||
return $this->belongsTo(Bettype::class);
|
||||
}
|
||||
|
||||
public function bookmaker()
|
||||
{
|
||||
return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid');
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class Odds3way extends Model
|
||||
|
||||
public function bookmaker()
|
||||
{
|
||||
return $this->belongsTo(Bookmaker::class);
|
||||
return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid');
|
||||
}
|
||||
|
||||
public function event()
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class BkmIconMap
|
||||
{
|
||||
public static function get($bookmaker)
|
||||
{
|
||||
if ($bookmaker) {
|
||||
return asset("storage/bookmaker-icons/$bookmaker->icon.png");
|
||||
} else {
|
||||
return asset('storage/bookmaker-icons/missing.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class BookmakerIcon
|
||||
{
|
||||
public static function byId($bkmid)
|
||||
{
|
||||
$image = '';
|
||||
switch ($bkmid) {
|
||||
case 5:
|
||||
$image = 'expekt.png';
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$image = 'unibet.jpg';
|
||||
break;
|
||||
|
||||
case 13:
|
||||
$image = 'sportingbet.png';
|
||||
break;
|
||||
|
||||
case 17:
|
||||
$image = 'ladbrokes.png';
|
||||
break;
|
||||
|
||||
case 30:
|
||||
$image = 'bwin.jpg';
|
||||
break;
|
||||
|
||||
case 42:
|
||||
$image = 'willhill.png';
|
||||
break;
|
||||
|
||||
case 110:
|
||||
$image = 'betfair.png';
|
||||
break;
|
||||
|
||||
case 314:
|
||||
$image = 'matchbook.png';
|
||||
break;
|
||||
|
||||
case 327:
|
||||
$image = 'sbobet.jpg';
|
||||
break;
|
||||
|
||||
case 388:
|
||||
$image = 'eurobet.png';
|
||||
break;
|
||||
|
||||
case 539:
|
||||
$image = 'marathonbet.png';
|
||||
break;
|
||||
|
||||
case 649:
|
||||
$image = '1xbet.jpg';
|
||||
break;
|
||||
|
||||
case 658:
|
||||
$image = 'bet9ja.png';
|
||||
break;
|
||||
|
||||
case 823:
|
||||
$image = 'betking.png';
|
||||
break;
|
||||
|
||||
case 824:
|
||||
$image = 'betplay.jpg';
|
||||
break;
|
||||
|
||||
case 825:
|
||||
$image = 'sportybet.png';
|
||||
break;
|
||||
|
||||
default:
|
||||
$image = 'missing.png';
|
||||
break;
|
||||
}
|
||||
|
||||
return asset("storage/bookmaker-icons/$image");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user