mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
proximitySearch added
This commit is contained in:
@@ -6,16 +6,20 @@ use App\Models\City;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
use WireUi\Traits\Actions;
|
||||
|
||||
class CityTable extends DataTableComponent
|
||||
{
|
||||
use Actions;
|
||||
|
||||
public string $country;
|
||||
|
||||
protected $model = City::class;
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
$this->setPrimaryKey('id');
|
||||
$this->setPrimaryKey('id')
|
||||
->setAdditionalSelects(['id']);
|
||||
}
|
||||
|
||||
public function columns(): array
|
||||
@@ -44,4 +48,15 @@ class CityTable extends DataTableComponent
|
||||
return City::query()
|
||||
->whereHas('country', fn($query) => $query->where('code', $this->country));
|
||||
}
|
||||
|
||||
public function proximitySearch($id)
|
||||
{
|
||||
$city = City::query()
|
||||
->find($id);
|
||||
$query = City::radius($city->latitude, $city->longitude, 100)
|
||||
->where('id', '!=', $id);
|
||||
$this->notification()
|
||||
->success('Proximity Search', 'Found '.$query->count().' cities. '.$query->pluck('name')
|
||||
->implode(', '));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ class EventTable extends DataTableComponent
|
||||
->sortable(),
|
||||
Column::make("Zuletzt geändert", "updated_at")
|
||||
->sortable(),
|
||||
Column::make("Teilnehmer")
|
||||
/*Column::make("Teilnehmer")
|
||||
->label(
|
||||
fn($row, Column $column) => '<strong>'.$row->registrations->count().'</strong>'
|
||||
)
|
||||
->html()
|
||||
->sortable(),
|
||||
->sortable(),*/
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.events.action')->withRow($row)
|
||||
|
||||
Reference in New Issue
Block a user