mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
filters changed
This commit is contained in:
15
app/Http/Livewire/BookCase/CityTable.php
Normal file
15
app/Http/Livewire/BookCase/CityTable.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\BookCase;
|
||||
|
||||
use App\Models\Country;
|
||||
use Livewire\Component;
|
||||
|
||||
class CityTable extends Component
|
||||
{
|
||||
public Country $country;
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.book-case.city-table');
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire\Tables;
|
||||
|
||||
use App\Models\BitcoinEvent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
|
||||
@@ -56,4 +57,10 @@ class BitcoinEventTable extends DataTableComponent
|
||||
->sortable(),
|
||||
];
|
||||
}
|
||||
|
||||
public function builder(): Builder
|
||||
{
|
||||
return BitcoinEvent::query()
|
||||
->whereHas('venue.city.country', fn($query) => $query->where('code', $this->country));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ class BookCaseTable extends DataTableComponent
|
||||
{
|
||||
return [
|
||||
TextFilter::make('By IDs', 'byids')
|
||||
->hiddenFromMenus()
|
||||
->filter(function (Builder $builder, string $value) {
|
||||
$builder->whereIn('id', str($value)->explode(','));
|
||||
}),
|
||||
|
||||
@@ -14,6 +14,7 @@ class CityTable extends DataTableComponent
|
||||
use Actions;
|
||||
|
||||
public string $country;
|
||||
public string $type;
|
||||
|
||||
protected $model = City::class;
|
||||
|
||||
@@ -39,25 +40,36 @@ class CityTable extends DataTableComponent
|
||||
|
||||
public function columns(): array
|
||||
{
|
||||
return [
|
||||
Column::make("Stadt Name", "name")
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Column::make('Veranstaltungs-Orte')
|
||||
->label(
|
||||
fn($row, Column $column) => $row->venues_count
|
||||
)
|
||||
->collapseOnMobile(),
|
||||
Column::make('Termine')
|
||||
->label(
|
||||
fn($row, Column $column) => $row->events_count
|
||||
)
|
||||
->collapseOnMobile(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.cities.action')->withRow($row)
|
||||
),
|
||||
];
|
||||
$columns = collect([]);
|
||||
if($this->type === 'school') {
|
||||
$columns = $columns->merge([
|
||||
Column::make('Veranstaltungs-Orte')
|
||||
->label(
|
||||
fn($row, Column $column) => $row->venues_count
|
||||
)
|
||||
->collapseOnMobile(),
|
||||
Column::make('Termine')
|
||||
->label(
|
||||
fn($row, Column $column) => $row->events_count
|
||||
)
|
||||
->collapseOnMobile(),
|
||||
]);
|
||||
}
|
||||
if ($this->type === 'bookCase') {
|
||||
$columns = $columns->merge([
|
||||
Column::make("Stadt Name", "name")
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.cities.action')
|
||||
->withRow($row)
|
||||
->withType($this->type)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
return $columns->toArray();
|
||||
}
|
||||
|
||||
public function builder(): Builder
|
||||
@@ -94,13 +106,18 @@ class CityTable extends DataTableComponent
|
||||
$city = City::query()
|
||||
->find($id);
|
||||
$query = BookCase::radius($city->latitude, $city->longitude, 5);
|
||||
$ids = $query->pluck('id');
|
||||
if ($ids->isEmpty()) {
|
||||
$this->notification()
|
||||
->error(__('No bookcases found in the radius of 5km'));
|
||||
return;
|
||||
}
|
||||
|
||||
return to_route('bookCases.table.bookcases', [
|
||||
'#table',
|
||||
'country' => $this->country,
|
||||
'table' => [
|
||||
'table' => [
|
||||
'filters' => [
|
||||
'byids' => $query->pluck('id')
|
||||
->implode(',')
|
||||
'byids' => $ids->implode(',')
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -71,6 +71,7 @@ class MeetupEventTable extends DataTableComponent
|
||||
public function builder(): Builder
|
||||
{
|
||||
return MeetupEvent::query()
|
||||
->whereHas('meetup.city.country', fn($query) => $query->where('code', $this->country))
|
||||
->with([
|
||||
'meetup',
|
||||
]);
|
||||
|
||||
@@ -55,6 +55,7 @@ class MeetupTable extends DataTableComponent
|
||||
public function builder(): Builder
|
||||
{
|
||||
return Meetup::query()
|
||||
->whereHas('city.country', fn($query) => $query->where('code', $this->country))
|
||||
->withCount([
|
||||
'meetupEvents',
|
||||
]);
|
||||
@@ -64,7 +65,7 @@ class MeetupTable extends DataTableComponent
|
||||
{
|
||||
return to_route('meetup.table.meetupEvent', [
|
||||
'country' => $this->country,
|
||||
'table' => [
|
||||
'table' => [
|
||||
'filters' => ['id' => $id],
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
<div class="flex flex-col space-y-1">
|
||||
<div>
|
||||
<x-button amber wire:click="proximitySearch({{ $row->id }})" class="text-21gray">
|
||||
<i class="fa fa-thin fa-person-chalkboard mr-2"></i>
|
||||
Umkreis-Suche Kurs-Termin {{ $row->name }} (100km)
|
||||
</x-button>
|
||||
</div>
|
||||
{{--<div>
|
||||
<x-button amber wire:click="proximitySearchForBookCases({{ $row->id }})" class="text-21gray">
|
||||
<i class="fa fa-thin fa-book mr-2"></i>
|
||||
Umkreis-Suche Bücher-Schrank {{ $row->name }} (5km)
|
||||
</x-button>
|
||||
</div>--}}
|
||||
@if($type === 'school')
|
||||
<div>
|
||||
<x-button amber wire:click="proximitySearch({{ $row->id }})" class="text-21gray">
|
||||
<i class="fa fa-thin fa-person-chalkboard mr-2"></i>
|
||||
Umkreis-Suche Kurs-Termin {{ $row->name }} (100km)
|
||||
</x-button>
|
||||
</div>
|
||||
@endif
|
||||
@if($type === 'bookCase')
|
||||
<div>
|
||||
<x-button amber wire:click="proximitySearchForBookCases({{ $row->id }})" class="text-21gray">
|
||||
<i class="fa fa-thin fa-book mr-2"></i>
|
||||
Umkreis-Suche Bücher-Schrank {{ $row->name }} (5km)
|
||||
</x-button>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
12
resources/views/livewire/book-case/city-table.blade.php
Normal file
12
resources/views/livewire/book-case/city-table.blade.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="bg-21gray flex flex-col h-screen justify-between">
|
||||
{{-- HEADER --}}
|
||||
<livewire:frontend.header :country="$country"/>
|
||||
{{-- MAIN --}}
|
||||
<section class="w-full mb-12">
|
||||
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10 space-y-4" id="table">
|
||||
<livewire:tables.city-table :country="$country->code" type="bookCase"/>
|
||||
</div>
|
||||
</section>
|
||||
{{-- FOOTER --}}
|
||||
<livewire:frontend.footer/>
|
||||
</div>
|
||||
@@ -51,6 +51,10 @@
|
||||
@endif
|
||||
@endif
|
||||
@if(str(request()->route()->getName())->contains('bookCases.'))
|
||||
<a href="{{ route('bookCases.table.city', ['country' => $c]) }}"
|
||||
class="{{ request()->routeIs('bookCases.table.city') ? 'text-amber-500 underline' : 'text-gray-400' }} mr-5 font-medium leading-6 hover:text-gray-300">
|
||||
Stadt-Suche
|
||||
</a>
|
||||
<a href="{{ route('bookCases.table.bookcases', ['country' => $c]) }}"
|
||||
class="{{ request()->routeIs('bookCases.table.bookcases') ? 'text-amber-500 underline' : 'text-gray-400' }} mr-5 font-medium leading-6 hover:text-gray-300">
|
||||
Bücher-Schränke
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
</div>
|
||||
<div
|
||||
class="row-span-2 col-span-full sm:col-span-1 md:col-start-3 xl:col-start-3 sm:row-start-3 md:row-start-1 xl:row-start-3">
|
||||
<a href="{{ route('bookCases.table.bookcases', ['country' => $c]) }}"
|
||||
<a href="{{ route('bookCases.table.city', ['country' => $c]) }}"
|
||||
class="relative flex flex-col items-start justify-end w-full h-full overflow-hidden bg-black shadow-lg rounded-xl group"
|
||||
style="aspect-ratio: 1/1;">
|
||||
<div class="absolute inset-0 w-full h-full">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{{-- MAIN --}}
|
||||
<section class="w-full mb-12">
|
||||
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10 space-y-4" id="table">
|
||||
<livewire:tables.city-table :country="$country->code"/>
|
||||
<livewire:tables.city-table :country="$country->code" type="school"/>
|
||||
</div>
|
||||
</section>
|
||||
{{-- FOOTER --}}
|
||||
|
||||
@@ -53,6 +53,9 @@ Route::middleware([])
|
||||
->as('bookCases.')
|
||||
->prefix('book-cases')
|
||||
->group(function () {
|
||||
Route::get('/{country:code}/table/city', \App\Http\Livewire\BookCase\CityTable::class)
|
||||
->name('table.city');
|
||||
|
||||
Route::get('/table/book-case', \App\Http\Livewire\BookCase\BookCaseTable::class)
|
||||
->name('table.bookcases');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user