add Custom Groups

This commit is contained in:
salam committed 2026-02-04 19:38:59 +01:00
1 parent c5118a4fd0
commit 6e7ebd7a9e
11 files changed
+216 -14

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Actions;
use App\Models\CompetitionGroup;
use App\Models\Country;
class LoadCountryGroups
{
public static function load()
{
$res = Country::query()->select('name', 'id')->get();
$countries = [];
foreach ($res as $value) {
$countries[$value->id] = $value->name;
}
$res = CompetitionGroup::where('sport_id', auth()->user()->sport_id)->select('country_id', 'name', 'id')->get();
$arr = [];
foreach ($res as $value) {
if (isset($countries[$value->country_id])) {
$arr[$value->id] = $countries[$value->country_id].' '.$value->name;
} else {
$arr[$value->id] = $value->name;
}
}
asort($arr);
return $arr;
}
}
@@ -10,6 +10,7 @@ use App\Filament\Tables\Columns\ColumnOdds;
use App\Filament\Tables\Columns\EventColumn;
use App\Filament\Tables\Columns\MatchIds;
use App\Filament\Tables\Columns\TooltipOdds;
use App\Models\ClientGroupList;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
@@ -180,7 +181,7 @@ class EventsTable
->extremePaginationLinks()
->filters([
Filter::make('events')
->columns(6)->columnSpan(6)
->columns(7)->columnSpan(7)
->schema([
Hidden::make('filter_alarm_green'),
Hidden::make('filter_alarm_yellow'),
@@ -253,6 +254,15 @@ class EventsTable
return $arr;
})
->live(),
Select::make('client_group_list_id')
->placeholder('Custom Groups')
->prefixIcon('phosphor-user-list')
->searchable()
->hiddenLabel()
->label('')
->preload()
->options(fn () => ClientGroupList::where('sport_id', auth()->user()->sport_id)->where('client_id', auth()->user()->client_id)->pluck('name', 'id'))
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(2)
@@ -290,6 +300,13 @@ class EventsTable
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
)->when(
$data['client_group_list_id'],
function (Builder $query, $client_group_list_id) {
$client_group_list_ids = ClientGroupList::where('id', $client_group_list_id)->value('client_groups');
$query->whereIn('competition_group_id', $client_group_list_ids);
}
)->when(
$data['starttime_period'],
function (Builder $query, $starttime_period) {
@@ -448,6 +465,11 @@ class EventsTable
}
}
if ($data['client_group_list_id'] ?? null) {
$client_group_list_name = ClientGroupList::where('id', $data['client_group_list_id'])->value('name');
$indicators[] = Indicator::make('Custom Group: '.$client_group_list_name)->removeField('client_group_list_id')->color('info');
}
if ($data['filter_stars'] ?? null) {
$indicators[] = Indicator::make('Filter Favorits')->removeField('filter_stars')->color('info');
}
+87
View File
@@ -0,0 +1,87 @@
<?php
namespace App\Livewire;
use App\Actions\LoadCountryGroups;
use App\Models\ClientGroupList;
use App\Models\CompetitionGroup;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Livewire\Component;
class ClientGroupListEditor extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
use InteractsWithSchemas;
use InteractsWithTable;
public function table(Table $table): Table
{
return $table
->query(ClientGroupList::query())
->columns([
TextColumn::make('name'),
TextColumn::make('client_groups')
->label('Leagues')
->badge()
->wrap()
->color('info')
->formatStateUsing(fn (string $state): string => CompetitionGroup::where('id', $state)->pluck('name')->first()),
])
->filters([
// ...
])
->recordActions([
EditAction::make('edit')
->iconButton()
->mutateDataUsing(function (array $data): array {
$data['client_id'] = auth()->user()->client_id;
$data['sport_id'] = auth()->user()->sport_id;
return $data;
})
->schema([
TextInput::make(name: 'name')
->required()
->maxLength(255),
Select::make('client_groups')
->searchable()
->multiple()
->preload()
->options(fn () => LoadCountryGroups::load()),
])->action(function ($livewire) {
$livewire->dispatch('refreshBettypeMenu');
}),
DeleteAction::make('delete')->iconButton(),
])
->headerActions([
CreateAction::make()
->label('New Group')
->schema([
TextInput::make(name: 'name')
->required()
->maxLength(255),
Select::make('client_groups')
->searchable()
->options(fn () => LoadCountryGroups::load()),
]),
]);
}
public function render(): View
{
return view('livewire.client-group-list-editor');
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ClientGroupList extends Model
{
protected $casts = [
'client_groups' => 'json',
];
protected $fillable = [
'name',
'sport_id',
'client_id',
'client_groups',
];
public function client_group()
{
return $this->belongsTo(CompetitionGroup::class)->with('country');
}
}
-5
View File
@@ -23,9 +23,4 @@ class CompetitionGroup extends Model
{
return $this->belongsTo(Sport::class);
}
public function country()
{
return $this->belongsTo(Country::class)->where('disabled', 0)->where('is_country', 1);
}
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('client_group_lists', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('sport_id')->index()->references('id')->on('sports');
$table->integer('client_id');
$table->text('client_groups')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('client_group_lists');
}
};
@@ -16,7 +16,7 @@
draggable="true"
mapper="left">
<div class="flex justify-center gap-4 w-full my-calendar">
<div class="flex justify-center gap-4 w-full my-calendar font-bold">
<div class="text-lime-500 text-wrap text-right">{{ $record->home->name }}</div>
<div>-</div>
<div class="text-sky-500 text-wrap">{{ $record->away->name }}</div>
@@ -24,7 +24,7 @@
@include('filament.tables.columns.parts.search-right', ['find' => $record->home, 'color' => 'away'])
</div>
<div class="flex justify-center gap-4 w-full">
<div class="flex justify-center gap-4 w-full font-bold">
<div class="text-sky-500 text-wrap text-right">{{ $record->home }}</div>
<div>-</div>
<div class="text-lime-500 text-wrap">{{ $record->away }}</div>
@@ -0,0 +1,7 @@
<div>
<x-sport-header>
{{ auth()->user()->sport->name }} - Custom Groups
</x-sport-header>
{{ $this->table }}
</div>
@@ -210,5 +210,15 @@
@livewire('comparing-bookmaker-menu')
</x-filament::modal>
{{-- Custom Groups --}}
<x-filament::modal slide-over width="3xl" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
<x-slot name="trigger">
<x-filament::icon-button outlined icon="phosphor-user-list" color="gray" class="my-auto"
title="Custom Groups">
</x-filament::icon-button>
</x-slot>
@livewire('client-group-list-editor')
</x-filament::modal>
@endif
</div>
-6
View File
@@ -14,12 +14,6 @@ tq shows 0 in odds
tq filter
if bkm in compere take from slot
MAPPER
1) add date select
2) submit with return
3) sort by date
4) click on lega for selection
4) window bigger
[PDF]
https://txodds.com/docs/TXODDS_TXAPI_Market_Odds_Feed_User_Guide.pdf