update meetups api, enriched with nextEvent data

This commit is contained in:
HolgerHatGarKeineNode
2023-09-28 20:33:39 +02:00
parent 6b3597fa2c
commit ca322e55b3
8 changed files with 523 additions and 495 deletions

View File

@@ -20,9 +20,9 @@ class MeetupController extends Controller
$myMeetupIds = User::query()->find($request->input('user_id'))->meetups->pluck('id'); $myMeetupIds = User::query()->find($request->input('user_id'))->meetups->pluck('id');
return Meetup::query() return Meetup::query()
->select('id', 'name', 'city_id') ->select('id', 'name', 'city_id', 'slug')
->with([ ->with([
'city', 'city.country',
]) ])
->whereIn('id', $myMeetupIds->toArray()) ->whereIn('id', $myMeetupIds->toArray())
->orderBy('name') ->orderBy('name')

View File

@@ -91,11 +91,6 @@ class Meetup extends Model implements HasMedia
return $this->belongsTo(City::class); return $this->belongsTo(City::class);
} }
public function meetupEvents(): HasMany
{
return $this->hasMany(MeetupEvent::class);
}
protected function logoSquare(): Attribute protected function logoSquare(): Attribute
{ {
$media = $this->getFirstMedia('logo'); $media = $this->getFirstMedia('logo');
@@ -116,4 +111,26 @@ class Meetup extends Model implements HasMedia
]), ]),
); );
} }
protected function nextEvent(): Attribute
{
$nextEvent = $this->meetupEvents()->where('start', '>=', now())->orderBy('start')->first();
return Attribute::make(
get: fn() => $nextEvent ? [
'start' => $nextEvent->start->toDateTimeString(),
'portalLink' => url()->route('meetup.event.landing', ['country' => $this->city->country, 'meetupEvent' => $nextEvent]),
'location' => $nextEvent->location,
'description' => $nextEvent->description,
'link' => $nextEvent->link,
'attendees' => count($nextEvent->attendees ?? []),
'nostr_note' => str($nextEvent->nostr_status)->after('Sent event ')->before(' to '),
] : null,
);
}
public function meetupEvents(): HasMany
{
return $this->hasMany(MeetupEvent::class);
}
} }

View File

@@ -63,7 +63,7 @@
"symfony/http-client": "^6.2", "symfony/http-client": "^6.2",
"symfony/mailgun-mailer": "^6.2", "symfony/mailgun-mailer": "^6.2",
"wesselperik/nova-status-field": "^2.1", "wesselperik/nova-status-field": "^2.1",
"wireui/wireui": "dev-main", "wireui/wireui": "^1.17.9",
"ziffmedia/nova-select-plus": "^2.0" "ziffmedia/nova-select-plus": "^2.0"
}, },
"require-dev": { "require-dev": {

906
composer.lock generated

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{ {
"/app.js": "/app.js?id=7e1968acfd75b8dc843675097962e3ce", "/app.js": "/app.js?id=ff1533ec4a7afad65c5bd7bcc2cc7d7b",
"/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435", "/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435",
"/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5", "/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f", "/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",

View File

@@ -72,11 +72,13 @@ Route::middleware([])
return \App\Models\Meetup::query() return \App\Models\Meetup::query()
->where('visible_on_map', true) ->where('visible_on_map', true)
->with([ ->with([
'city', 'meetupEvents',
'city.country',
]) ])
->get() ->get()
->map(fn($meetup) => [ ->map(fn($meetup) => [
'name' => $meetup->name, 'name' => $meetup->name,
'portalLink' => url()->route('meetup.landing', ['country' => $meetup->city->country, 'meetup' => $meetup]),
'url' => $meetup->telegram_link ?? $meetup->webpage, 'url' => $meetup->telegram_link ?? $meetup->webpage,
'top' => $meetup->github_data['top'] ?? null, 'top' => $meetup->github_data['top'] ?? null,
'left' => $meetup->github_data['left'] ?? null, 'left' => $meetup->github_data['left'] ?? null,
@@ -87,6 +89,7 @@ Route::middleware([])
'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,
'next_event' => $meetup->nextEvent,
]); ]);
}); });
Route::get('btc-map-communities', function () { Route::get('btc-map-communities', function () {

View File

@@ -3428,13 +3428,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"js-confetti@npm:^0.11.0":
version: 0.11.0
resolution: "js-confetti@npm:0.11.0"
checksum: 6bd280952842bb9cf0587042fe8f716423bc1e8a652145aeaefb68c70480be4477ae9ff556e569a7fa05763e8e24d0d2700d9cf88e7f210261e83069deb74dbf
languageName: node
linkType: hard
"js-tokens@npm:^4.0.0": "js-tokens@npm:^4.0.0":
version: 4.0.0 version: 4.0.0
resolution: "js-tokens@npm:4.0.0" resolution: "js-tokens@npm:4.0.0"
@@ -4932,7 +4925,6 @@ __metadata:
"@tailwindcss/typography": ^0.5.0 "@tailwindcss/typography": ^0.5.0
alpinejs: ^3.0.6 alpinejs: ^3.0.6
autoprefixer: ^10.4.7 autoprefixer: ^10.4.7
js-confetti: ^0.11.0
laravel-echo: ^1.15.0 laravel-echo: ^1.15.0
laravel-vite-plugin: ^0.7.2 laravel-vite-plugin: ^0.7.2
leaflet.heat: ^0.2.0 leaflet.heat: ^0.2.0