add visible_on_map field to meetups table

This commit is contained in:
HolgerHatGarKeineNode
2023-08-07 15:43:13 +02:00
parent 1339b49a33
commit 34e065a06e
6 changed files with 174 additions and 143 deletions

View File

@@ -22,7 +22,7 @@ class MeetupEventTable extends Component
public function mount() public function mount()
{ {
if (! $this->year) { if (!$this->year) {
$this->year = now()->year; $this->year = now()->year;
} }
} }
@@ -31,16 +31,17 @@ class MeetupEventTable extends Component
{ {
return view('livewire.meetup.meetup-event-table', [ return view('livewire.meetup.meetup-event-table', [
'markers' => MeetupEvent::query() 'markers' => MeetupEvent::query()
->where('visible_on_map', true)
->with([ ->with([
'meetup.city.country', 'meetup.city.country',
]) ])
->where('meetup_events.start', '>=', now()->subDay()) ->where('meetup_events.start', '>=', now()->subDay())
->whereHas('meetup.city.country', ->whereHas('meetup.city.country',
fn ($query) => $query->where('countries.code', $this->country->code)) fn($query) => $query->where('countries.code', $this->country->code))
->get() ->get()
->map(fn ($event) => [ ->map(fn($event) => [
'id' => $event->id, 'id' => $event->id,
'name' => $event->meetup->name.': '.$event->location, 'name' => $event->meetup->name . ': ' . $event->location,
'coords' => [$event->meetup->city->latitude, $event->meetup->city->longitude], 'coords' => [$event->meetup->city->latitude, $event->meetup->city->longitude],
]), ]),
'events' => MeetupEvent::query() 'events' => MeetupEvent::query()
@@ -49,9 +50,9 @@ class MeetupEventTable extends Component
]) ])
->where('meetup_events.start', '>=', now()->subDay()) ->where('meetup_events.start', '>=', now()->subDay())
->whereHas('meetup.city.country', ->whereHas('meetup.city.country',
fn ($query) => $query->where('countries.code', $this->country->code)) fn($query) => $query->where('countries.code', $this->country->code))
->get() ->get()
->map(fn ($event) => [ ->map(fn($event) => [
'id' => $event->id, 'id' => $event->id,
'startDate' => $event->start, 'startDate' => $event->start,
'endDate' => $event->start->addHours(1), 'endDate' => $event->start->addHours(1),

View File

@@ -31,6 +31,7 @@ class MeetupTable extends Component
return view('livewire.meetup.meetup-table', [ return view('livewire.meetup.meetup-table', [
'markers' => Meetup::query() 'markers' => Meetup::query()
->where('visible_on_map', true)
->with([ ->with([
'city.country', 'city.country',
]) ])

View File

@@ -26,11 +26,12 @@ class WorldMap extends Component
{ {
return view('livewire.meetup.world-map', [ return view('livewire.meetup.world-map', [
'allMarkers' => Meetup::query() 'allMarkers' => Meetup::query()
->where('visible_on_map', true)
->with([ ->with([
'city.country', 'city.country',
]) ])
->get() ->get()
->map(fn ($meetup) => [ ->map(fn($meetup) => [
'id' => $meetup->id, 'id' => $meetup->id,
'name' => $meetup->name, 'name' => $meetup->name,
'coords' => [$meetup->city->latitude, $meetup->city->longitude], 'coords' => [$meetup->city->latitude, $meetup->city->longitude],

View File

@@ -0,0 +1,27 @@
<?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::table('meetups', function (Blueprint $table) {
$table->boolean('visible_on_map')->default(true);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('meetups', function (Blueprint $table) {
//
});
}
};

View File

@@ -35,6 +35,7 @@ Route::middleware([])
Route::resource('languages', \App\Http\Controllers\Api\LanguageController::class); Route::resource('languages', \App\Http\Controllers\Api\LanguageController::class);
Route::get('meetups', function () { Route::get('meetups', function () {
return \App\Models\Meetup::query() return \App\Models\Meetup::query()
->where('visible_on_map', true)
->with([ ->with([
'city', 'city',
]) ])
@@ -47,8 +48,8 @@ Route::middleware([])
'country' => str($meetup->city->country->code)->upper(), 'country' => str($meetup->city->country->code)->upper(),
'state' => $meetup->github_data['state'] ?? null, 'state' => $meetup->github_data['state'] ?? null,
'city' => $meetup->city->name, 'city' => $meetup->city->name,
'longitude' => (float) $meetup->city->longitude, 'longitude' => (float)$meetup->city->longitude,
'latitude' => (float) $meetup->city->latitude, 'latitude' => (float)$meetup->city->latitude,
'twitter_username' => $meetup->twitter_username, 'twitter_username' => $meetup->twitter_username,
'website' => $meetup->webpage, 'website' => $meetup->webpage,
]); ]);
@@ -76,7 +77,7 @@ Route::middleware([])
'continent' => 'europe', 'continent' => 'europe',
'icon:square' => $meetup->logoSquare, 'icon:square' => $meetup->logoSquare,
//'contact:email' => null, //'contact:email' => null,
'contact:twitter' => $meetup->twitter_username ? 'https://twitter.com/'.$meetup->twitter_username : null, 'contact:twitter' => $meetup->twitter_username ? 'https://twitter.com/' . $meetup->twitter_username : null,
'contact:website' => $meetup->webpage, 'contact:website' => $meetup->webpage,
'contact:telegram' => $meetup->telegram_link, 'contact:telegram' => $meetup->telegram_link,
'contact:nostr' => $meetup->nostr, 'contact:nostr' => $meetup->nostr,
@@ -116,7 +117,7 @@ Route::get('/lnurl-auth-callback', function (Request $request) {
'public_key' => $request->key, 'public_key' => $request->key,
'is_lecturer' => true, 'is_lecturer' => true,
'name' => $fakeName, 'name' => $fakeName,
'email' => str($request->key)->substr(-12).'@portal.einundzwanzig.space', 'email' => str($request->key)->substr(-12) . '@portal.einundzwanzig.space',
'lnbits' => [ 'lnbits' => [
'read_key' => null, 'read_key' => null,
'url' => null, 'url' => null,
@@ -126,7 +127,7 @@ Route::get('/lnurl-auth-callback', function (Request $request) {
$user->ownedTeams() $user->ownedTeams()
->save(Team::forceCreate([ ->save(Team::forceCreate([
'user_id' => $user->id, 'user_id' => $user->id,
'name' => $fakeName."'s Team", 'name' => $fakeName . "'s Team",
'personal_team' => true, 'personal_team' => true,
])); ]));
} }

View File

@@ -729,9 +729,9 @@ __metadata:
linkType: hard linkType: hard
"caniuse-lite@npm:^1.0.30001426, caniuse-lite@npm:^1.0.30001449": "caniuse-lite@npm:^1.0.30001426, caniuse-lite@npm:^1.0.30001449":
version: 1.0.30001450 version: 1.0.30001519
resolution: "caniuse-lite@npm:1.0.30001450" resolution: "caniuse-lite@npm:1.0.30001519"
checksum: 511b360bfc907b2e437699364cf96b83507bc45043926450056642332bcd6f65a1e72540c828534ae15e0ac906e3e9af46cb2bb84458dd580bc31478e9dce282 checksum: 66085133ede05d947e30b62fed2cbae18e5767afda8b0de38840883e1cfe5846bf1568ddbafd31647544e59112355abedaf9c867ac34541bfc20d69e7a19d94c
languageName: node languageName: node
linkType: hard linkType: hard