mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
update meetups api, enriched with nextEvent data
This commit is contained in:
@@ -20,23 +20,23 @@ 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')
|
||||||
->when(
|
->when(
|
||||||
$request->search,
|
$request->search,
|
||||||
fn (Builder $query) => $query
|
fn(Builder $query) => $query
|
||||||
->where('name', 'like', "%{$request->search}%")
|
->where('name', 'like', "%{$request->search}%")
|
||||||
->orWhereHas('city',
|
->orWhereHas('city',
|
||||||
fn (Builder $query) => $query->where('cities.name', 'ilike', "%{$request->search}%"))
|
fn(Builder $query) => $query->where('cities.name', 'ilike', "%{$request->search}%"))
|
||||||
)
|
)
|
||||||
->when(
|
->when(
|
||||||
$request->exists('selected'),
|
$request->exists('selected'),
|
||||||
fn (Builder $query) => $query->whereIn('id', $request->input('selected', [])),
|
fn(Builder $query) => $query->whereIn('id', $request->input('selected', [])),
|
||||||
fn (Builder $query) => $query->limit(10)
|
fn(Builder $query) => $query->limit(10)
|
||||||
)
|
)
|
||||||
->get()
|
->get()
|
||||||
->map(function (Meetup $meetup) {
|
->map(function (Meetup $meetup) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Meetup extends Model implements HasMedia
|
|||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::creating(function ($model) {
|
static::creating(function ($model) {
|
||||||
if (! $model->created_by) {
|
if (!$model->created_by) {
|
||||||
$model->created_by = auth()->id();
|
$model->created_by = auth()->id();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -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');
|
||||||
@@ -106,7 +101,7 @@ class Meetup extends Model implements HasMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: fn () => url()->route('img',
|
get: fn() => url()->route('img',
|
||||||
[
|
[
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'w' => 900,
|
'w' => 900,
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
906
composer.lock
generated
File diff suppressed because it is too large
Load Diff
2
public/vendor/horizon/app.js
vendored
2
public/vendor/horizon/app.js
vendored
File diff suppressed because one or more lines are too long
2
public/vendor/horizon/mix-manifest.json
vendored
2
public/vendor/horizon/mix-manifest.json
vendored
@@ -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",
|
||||||
|
|||||||
@@ -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 () {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user