filter start ok
This commit is contained in:
1 parent
b01e7c98fc
commit
a1057d55a7
3 files changed
+61
-19
No files matched your search
@@ -17,6 +17,7 @@ use App\Filament\Tables\Columns\ColumnTotalQ1;
|
||||
use App\Filament\Tables\Columns\ColumnTq;
|
||||
use App\Filament\Tables\Columns\MatchIds;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventUserStar;
|
||||
@@ -33,11 +34,11 @@ use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\VerticalAlignment;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -223,9 +224,11 @@ class EventsTable
|
||||
Filter::make('events')
|
||||
->schema([
|
||||
Select::make(name: 'country_id')
|
||||
->columnSpan(2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function () {
|
||||
@@ -239,6 +242,7 @@ class EventsTable
|
||||
$set('competition_group_id', null);
|
||||
}),
|
||||
Select::make('competition_group_id')
|
||||
->columnSpan(2)
|
||||
->placeholder('League')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
@@ -260,7 +264,7 @@ class EventsTable
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->startPrefix('From')
|
||||
->columnSpan(2)
|
||||
->displayFormat('d M Y')
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
@@ -272,21 +276,11 @@ class EventsTable
|
||||
// ->offIcon('phosphor-star')
|
||||
// ->offColor('gray')
|
||||
// ->live(),
|
||||
// Action::make('resetAction')
|
||||
// ->hiddenLabel()
|
||||
// ->color('primary')
|
||||
// ->outlined()
|
||||
// ->keyBindings(['esc', 'escape'])
|
||||
// ->icon('phosphor-x')
|
||||
// ->action(function ($livewire) {
|
||||
// $livewire->resetTableFiltersForm(); // Clears all filters
|
||||
// $livewire->tableSearch = ''; // Clears the main search bar
|
||||
// }),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['stars_status'],
|
||||
auth()->user()->stars,
|
||||
fn (Builder $query) => $query->whereHas('event_user_star')
|
||||
)
|
||||
->when(
|
||||
@@ -318,10 +312,51 @@ class EventsTable
|
||||
}
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['country_id'] ?? null) {
|
||||
$countries = $data['country_id'];
|
||||
if (is_array($countries)) {
|
||||
$countries = Country::whereIn('id', $countries)->pluck('name')->toArray();
|
||||
$indicators[] = Indicator::make('Countries: '.implode(', ', $countries))->removeField('country_id');
|
||||
} else {
|
||||
$indicators[] = Indicator::make('Country: '.Country::find($countries)->value('name'))->removeField('country_id');
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['competition_group_id'] ?? null) {
|
||||
$competition_group_ids = $data['competition_group_id'];
|
||||
if (is_array($competition_group_ids)) {
|
||||
$countries = CompetitionGroup::whereIn('id', $competition_group_ids)->pluck('name')->toArray();
|
||||
$indicators[] = Indicator::make('Leagues: '.implode(', ', $countries))->removeField('competition_group_id');
|
||||
} else {
|
||||
$indicators[] = Indicator::make('League: '.CompetitionGroup::find($competition_group_ids)->value('name'))->removeField('competition_group_id');
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['starttime_period'] ?? null) {
|
||||
$span = $data['starttime_period'];
|
||||
$text = '';
|
||||
if ($span['start'] ?? null) {
|
||||
$text .= 'From '.Carbon::parse($span['start'])->toFormattedDateString();
|
||||
}
|
||||
if ($span['end'] ?? null) {
|
||||
$text .= ' To '.Carbon::parse($span['end'])->toFormattedDateString();
|
||||
}
|
||||
if ($text) {
|
||||
$indicators[] = Indicator::make($text)->removeField('starttime_period.start');
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['stars_status'] ?? null) {
|
||||
$indicators[] = Indicator::make('Favorits')->removeField('stars_status');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
->columns(1)->columnSpan(1),
|
||||
->columns(2)->columnSpan(2),
|
||||
], layout: FiltersLayout::Modal)
|
||||
->filtersFormWidth(Width::TwoExtraLarge)
|
||||
->deferFilters(false)
|
||||
->persistFiltersInSession()
|
||||
->recordActions([
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -44,4 +45,11 @@ class BettypeToggle extends Component
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
}
|
||||
|
||||
public function toggleStar()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['stars' => DB::raw('!stars')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
<div class="flex flex-row gap-3">
|
||||
<x-filament::button icon="phosphor-x" outlined>
|
||||
</x-filament::button>
|
||||
@foreach ($bettype_toggles as $toggle)
|
||||
<x-filament::button size="xs" class="flex flex-col justify-center gap-0" tooltip="{{ $toggle['name'] }}"
|
||||
wire:click="toggleBettype({{ $toggle['id'] }})" wire:dispatch="refreshTable" :color="!$toggle['is_active'] ? 'gray' : 'primary'">
|
||||
wire:click="toggleBettype({{ $toggle['id'] }})" :color="!$toggle['is_active'] ? 'gray' : 'primary'">
|
||||
<div class="m-0 p-0">{{ $toggle['short'] }}</div>
|
||||
{{-- <div class="m-0 p-0" style="font-size:9px">{{ $toggle['matchpart'] }}</div> --}}
|
||||
</x-filament::button>
|
||||
@endforeach
|
||||
<x-filament::button size="xs" outlined color="gray" wire:click="toggleStar" :color="auth()->user()->stars ? 'primary' : 'gray'" :icon="auth()->user()->stars ? 'phosphor-star-fill' : 'phosphor-star'">
|
||||
</x-filament::button>
|
||||
</div>
|
||||
Reference in new issue
Block a user