partner programm completed

This commit is contained in:
salam committed 2026-01-29 20:20:31 +01:00
1 parent 84bfa248cd
commit a883ccf0ea
22 files changed
+722 -28

No files matched your search

+1
View File
@@ -16,6 +16,7 @@ class AlarmStatistic
}
$res = EventBookmaker::select('alarm_2w_h2w', 'alarm_2w_a2w', 'alarm_2ws1_h2w', 'alarm_2ws1_a2w', 'alarm_3w_h3w', 'alarm_3w_d3w', 'alarm_3w_a3w', 'alarm_3wht_h3w', 'alarm_3wht_d3w', 'alarm_3wht_a3w', 'alarm_dc_dc1x', 'alarm_dc_dc12', 'alarm_dc_dcx2', 'alarm_dbn_dnb1', 'alarm_dbn_dnb2', 'alarm_ggng_gg', 'alarm_ggng_ng', 'alarm_po_home', 'alarm_po_away', 'alarm_poht_home', 'alarm_poht_away', 'alarm_poq1_home', 'alarm_poq1_away', 'alarm_to_over', 'alarm_to_under', 'alarm_toht_over', 'alarm_toht_under', 'alarm_toq1_over', 'alarm_toq1_under', 'alarm_tq_htq', 'alarm_tq_atq')
->where('starttime', '>=', now())
->where('bookmaker_id', auth()->user()->bookmaker_id)
->where('sport_id', auth()->user()->sport_id)
->get()
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Events;
use App\Filament\Resources\Events\Pages\ListEvents;
use App\Filament\Resources\Events\Schemas\EventForm;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences;
use App\Models\Event;
use Carbon\Carbon;
use Filament\Resources\Resource;
@@ -76,6 +77,11 @@ class EventResource extends Resource
}
}
if (auth()->user()->partner_compare) {
$event_ids = LoadPartnerDifferences::load();
$query->whereIn('id', $event_ids);
}
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
$query->with('odds_2ways.bookmaker');
}
@@ -17,7 +17,9 @@ class ListEvents extends ListRecords
'refreshBettypeMenu' => '$refresh',
'filterUpdateGreen' => 'updateTableFiltersGreen',
'filterUpdateYellow' => 'updateTableFiltersYellow',
'filterUpdateRed' => 'updateTableFiltersRed'];
'filterUpdateRed' => 'updateTableFiltersRed',
'filterUpdatePeriode' => 'updateTablePeriode',
];
protected function getHeaderWidgets(): array
{
@@ -26,6 +28,13 @@ class ListEvents extends ListRecords
];
}
public function updateTablePeriode(string $filter): void
{
$filter = json_decode($filter, true);
$this->tableFilters['events']['starttime_period']['start'] = $filter['start'];
$this->tableFilters['events']['starttime_period']['end'] = $filter['end'];
}
public function updateTableFiltersGreen(string $filter): void
{
$this->tableFilters['events']['filter_alarm_yellow'] = null;
@@ -346,6 +346,9 @@ class EventsTable
)->when(
$data['starttime_period'],
function (Builder $query, $starttime_period) {
// dd($starttime_period);
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
$from = Carbon::createFromDate($starttime_period['start']);
$end = Carbon::createFromDate($starttime_period['end']);
@@ -462,17 +465,17 @@ class EventsTable
if ($data['filter_alarm_green'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_green'])->value('title');
$indicators[] = Indicator::make('Alarm: '.$title)->removeField('filter_alarm_green')->color('success');
$indicators[] = Indicator::make('Alarms: '.$title)->removeField('filter_alarm_green')->color('success');
}
if ($data['filter_alarm_yellow'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_yellow'])->value('title');
$indicators[] = Indicator::make('Alarm: '.$title)->removeField('filter_alarm_yellow')->color('warning');
$indicators[] = Indicator::make('Alarms: '.$title)->removeField('filter_alarm_yellow')->color('warning');
}
if ($data['filter_alarm_red'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_red'])->value('title');
$indicators[] = Indicator::make('Alarm: '.$title)->removeField('filter_alarm_red')->color('danger');
$indicators[] = Indicator::make('Alarms: '.$title)->removeField('filter_alarm_red')->color('danger');
}
if ($data['starttime_period'] ?? null) {
@@ -526,10 +529,18 @@ class EventsTable
->deferFilters(false)
->hiddenFilterIndicators(false)
->persistFiltersInSession()
->emptyStateHeading('No events')
->emptyStateDescription('Modify the filter')
->recordActions([
Action::make('star')
->iconButton()
->color('gray')
->color(function ($record) {
if (isset($record->event_user_star->id)) {
return 'info';
} else {
return 'gray';
}
})
->icon(function ($record) {
if (isset($record->event_user_star->id)) {
return 'phosphor-star-fill';
@@ -0,0 +1,41 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\OddsTable;
use Illuminate\Support\Facades\DB;
class LoadPartnerDifferences
{
public static function load()
{
$fields = OddsTable::fields();
$event_ids = [];
foreach (EventsTable::$bettype_settings as $table) {
$books = DB::table($table)
->where('bookmaker_id', auth()->user()->bookmaker_id)
->get();
$partners = DB::table($table)
->where('bookmaker_id', auth()->user()->partner_bookmaker_id)
->get();
foreach ($books as $book) {
$row1 = get_object_vars($book);
foreach ($partners as $partner) {
$row2 = get_object_vars($partner);
if ($row1['event_id'] == $row2['event_id']) {
foreach ($fields[$table] as $field) {
if ($row1[$field] != $row2[$field]) {
$event_ids[] = $row1['event_id'];
}
}
}
}
}
}
return array_unique($event_ids);
}
}
@@ -21,6 +21,9 @@ class AlarmWidget extends StatsOverviewWidget
protected function getStats(): array
{
if (auth()->user()->partner_show) {
return [];
}
$res = AlarmStatistic::load();
@@ -23,14 +23,6 @@ class UserForm
Select::make('client_id')
->relationship('client', 'name')
->preload(),
Select::make('bookmaker_id')
->label('Active Bookmaker')
->options(function () {
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
})
->preload(),
Select::make('roles')
->label('Rollen')
->prefixIcon('phosphor-gear')
@@ -40,6 +32,22 @@ class UserForm
->multiple()
->preload()
->searchable(),
Select::make('bookmaker_id')
->label('Active Bookmaker')
->options(function () {
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
})
->preload(),
Select::make('partner_bookmaker_id')
->label('Partner Bookmaker')
->options(function () {
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
})
->preload(),
]);
}
}
@@ -27,6 +27,10 @@ class UsersTable
->label('Active Bookmaker')
->badge()
->color('warning'),
TextColumn::make('partnerbookmaker.name')
->label('Partner Bookmaker')
->badge()
->color('warning'),
])
->filters([
//
@@ -3,6 +3,7 @@
namespace App\Filament\Tables\Columns;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\Bookmaker;
use Filament\Tables\Columns\Column;
class ColumnOdds extends Column
@@ -29,6 +30,10 @@ class ColumnOdds extends Column
public $compare;
public $partner;
public $partner_icon;
protected ?array $odds_labels;
protected bool $state = true;
@@ -43,6 +48,8 @@ class ColumnOdds extends Column
return;
}
$this->setPartnerIcon();
$this->setSlots();
$this->has_data = count($this->data);
@@ -81,6 +88,11 @@ class ColumnOdds extends Column
return $this->columns;
}
public function getPartnerBookmakerIcon()
{
return $this->partner_icon;
}
public function getSlots()
{
if (auth()->user()->is_multiline_direct) {
@@ -105,6 +117,11 @@ class ColumnOdds extends Column
return $this->compare;
}
public function getPartner()
{
return $this->partner;
}
public function getMax()
{
return $this->max;
@@ -118,76 +135,91 @@ class ColumnOdds extends Column
public function getData($record)
{
$this->client = null;
$this->partner = null;
$this->data = null;
switch ($this->bettype) {
case 'odds_2ways':
$this->data = $record->odds_2ways;
$this->client = $record->odds_2ways->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_2ways->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_2ways_s1':
$this->data = $record->odds_2ways_s1;
$this->client = $record->odds_2ways_s1->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_2ways_s1->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_3ways':
$this->data = $record->odds_3ways;
$this->client = $record->odds_3ways->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_3ways->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_3ways_ht':
$this->data = $record->odds_3ways_ht;
$this->client = $record->odds_3ways_ht->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_3ways_ht->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_dc':
$this->data = $record->odds_dc;
$this->client = $record->odds_dc->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_dc->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_dnb':
$this->data = $record->odds_dnb;
$this->client = $record->odds_dnb->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_dnb->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_ggng':
$this->data = $record->odds_ggng;
$this->client = $record->odds_ggng->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_ggng->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_points':
$this->data = $record->odds_points;
$this->client = $record->odds_points->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_points->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_points_ht':
$this->data = $record->odds_points_ht;
$this->client = $record->odds_points_ht->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_points_ht->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_points_q1':
$this->data = $record->odds_points_q1;
$this->client = $record->odds_points_q1->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_points_q1->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_totals':
$this->data = $record->odds_totals;
$this->client = $record->odds_totals->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_totals->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_totals_ht':
$this->data = $record->odds_totals_ht;
$this->client = $record->odds_totals_ht->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_totals_ht->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_totals_q1':
$this->data = $record->odds_totals_q1;
$this->client = $record->odds_totals_q1->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_totals_q1->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
case 'odds_tq':
$this->data = $record->odds_tq;
$this->client = $record->odds_tq->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->partner = $record->odds_tq->where('bookmaker_id', auth()->user()->partner_bookmaker_id)->first();
break;
}
@@ -342,6 +374,11 @@ class ColumnOdds extends Column
});
}
public function setPartnerIcon()
{
$this->partner_icon = Bookmaker::where('id', auth()->user()->partner_bookmaker_id)->value('icon');
}
public function setSlots()
{
$this->slots = EventsTable::$slots[$this->bettype];
+33
View File
@@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Models\BettypeUser;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Livewire\Component;
@@ -53,6 +54,20 @@ class BettypeToggle extends Component
$this->dispatch('refreshBettypeMenu');
}
public function toggleShowPartner()
{
User::where('id', auth()->user()->id)->update(['partner_compare' => 0, 'partner_show' => DB::raw('!partner_show')]);
$this->dispatch('refreshBettypeMenu');
}
public function toggleComparePartner()
{
User::where('id', auth()->user()->id)->update(['partner_compare' => DB::raw('!partner_compare')]);
$this->dispatch('refreshBettypeMenu');
}
public function toggleMultiline()
{
User::where('id', auth()->user()->id)->update(['is_multiline_direct' => DB::raw('!is_multiline_direct')]);
@@ -60,6 +75,24 @@ class BettypeToggle extends Component
$this->dispatch('refreshBettypeMenu');
}
public function setToday()
{
$data = [
'start' => Carbon::today()->format('Y-m-d 00:00:00'),
'end' => Carbon::tomorrow()->format('Y-m-d 00:00:00'),
];
$this->dispatch('filterUpdatePeriode', json_encode($data));
}
public function setTomorrow()
{
$data = [
'start' => Carbon::tomorrow()->format('Y-m-d 00:00:00'),
'end' => Carbon::tomorrow()->addDay()->format('Y-m-d 00:00:00'),
];
$this->dispatch('filterUpdatePeriode', json_encode($data));
}
public function toggelAllOnlyNone()
{
+8 -1
View File
@@ -24,8 +24,15 @@ class KontoSwitcher extends Component
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
$bookmaker_id = array_shift($bookmakers);
$partner_bookmaker_id = array_shift($bookmakers) ?? 0;
User::where('id', auth()->user()->id)->update(['sport_id' => 1, 'provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
User::where('id', auth()->user()->id)->update([
'sport_id' => 1,
'provider_id' => $provider_id,
'bookmaker_id' => $bookmaker_id,
'partner_bookmaker_id' => $partner_bookmaker_id,
'client_id' => $client_id,
]);
$this->js('window.location.reload()');
}
+1 -1
View File
@@ -41,7 +41,7 @@ class TopMenuItems extends Component
{
$provider_id = Provider::where('bookmaker_id', $bookmaker_id)->value('id');
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id]);
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'partner_bookmaker_id' => auth()->user()->bookmaker_id]);
$this->js('window.location.reload()');
}
+11
View File
@@ -19,4 +19,15 @@ class OddsTable extends Model
return $arr;
}
public static function fields()
{
$res = OddsTable::get();
$arr = [];
foreach ($res as $value) {
$arr[$value->name] = explode(',', $value->oddnames);
}
return $arr;
}
}
+8
View File
@@ -37,7 +37,10 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
'star',
'is_multiline_direct',
'all_only_none',
'partner_show',
'partner_compare',
'bookmaker_id',
'partner_bookmaker_id',
'provider_id',
];
@@ -159,6 +162,11 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
return $this->belongsTo(Bookmaker::class);
}
public function partnerbookmaker()
{
return $this->belongsTo(Bookmaker::class, 'partner_bookmaker_id', 'id');
}
public function sport()
{
return $this->belongsTo(Sport::class);