wip
This commit is contained in:
1 parent
a26c555b05
commit
cec5a5e2f7
20 files changed
+211
-120
No files matched your search
@@ -13,7 +13,7 @@ use App\Models\BettypeUser;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\MultilineClient;
|
||||
use Carbon\Carbon;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
@@ -28,6 +28,7 @@ use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class EventsTable
|
||||
{
|
||||
@@ -235,13 +236,30 @@ class EventsTable
|
||||
}
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->competition_group_id] = $val->country?->name.' - '.$val->competition_group->name;
|
||||
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group->name;
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->columnSpan(2)
|
||||
->startPrefix('From')
|
||||
->displayFormat('d M Y')
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->live(),
|
||||
Action::make('reset')
|
||||
->hiddenLabel()
|
||||
->color('gray')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function ($livewire) {
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$livewire->tableSearch = ''; // Clears the main search bar
|
||||
}),
|
||||
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
@@ -251,6 +269,28 @@ class EventsTable
|
||||
)->when(
|
||||
$data['competition_group_id'],
|
||||
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
|
||||
)->when(
|
||||
$data['starttime_period'],
|
||||
function (Builder $query, $starttime_period) {
|
||||
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from->format('Y-m-d 00:00:00'))
|
||||
->where('starttime', '<=', $end->format('Y-m-d 00:00:00'));
|
||||
} elseif (isset($starttime_period['start'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from->format('Y-m-d 00:00:00'));
|
||||
} elseif (isset($starttime_period['end'])) {
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '<=', $end->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
}
|
||||
);
|
||||
})
|
||||
->columns(6)->columnSpan(6),
|
||||
|
||||
Reference in new issue
Block a user