partner programm completed
This commit is contained in:
1 parent
84bfa248cd
commit
a883ccf0ea
22 files changed
+722
-28
No files matched your search
@@ -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([
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user