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,30 +20,30 @@ class MeetupController extends Controller
|
||||
$myMeetupIds = User::query()->find($request->input('user_id'))->meetups->pluck('id');
|
||||
|
||||
return Meetup::query()
|
||||
->select('id', 'name', 'city_id')
|
||||
->with([
|
||||
'city',
|
||||
])
|
||||
->whereIn('id', $myMeetupIds->toArray())
|
||||
->orderBy('name')
|
||||
->when(
|
||||
$request->search,
|
||||
fn (Builder $query) => $query
|
||||
->where('name', 'like', "%{$request->search}%")
|
||||
->orWhereHas('city',
|
||||
fn (Builder $query) => $query->where('cities.name', 'ilike', "%{$request->search}%"))
|
||||
)
|
||||
->when(
|
||||
$request->exists('selected'),
|
||||
fn (Builder $query) => $query->whereIn('id', $request->input('selected', [])),
|
||||
fn (Builder $query) => $query->limit(10)
|
||||
)
|
||||
->get()
|
||||
->map(function (Meetup $meetup) {
|
||||
$meetup->profile_image = $meetup->getFirstMediaUrl('logo', 'thumb');
|
||||
->select('id', 'name', 'city_id', 'slug')
|
||||
->with([
|
||||
'city.country',
|
||||
])
|
||||
->whereIn('id', $myMeetupIds->toArray())
|
||||
->orderBy('name')
|
||||
->when(
|
||||
$request->search,
|
||||
fn(Builder $query) => $query
|
||||
->where('name', 'like', "%{$request->search}%")
|
||||
->orWhereHas('city',
|
||||
fn(Builder $query) => $query->where('cities.name', 'ilike', "%{$request->search}%"))
|
||||
)
|
||||
->when(
|
||||
$request->exists('selected'),
|
||||
fn(Builder $query) => $query->whereIn('id', $request->input('selected', [])),
|
||||
fn(Builder $query) => $query->limit(10)
|
||||
)
|
||||
->get()
|
||||
->map(function (Meetup $meetup) {
|
||||
$meetup->profile_image = $meetup->getFirstMediaUrl('logo', 'thumb');
|
||||
|
||||
return $meetup;
|
||||
});
|
||||
return $meetup;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ class Meetup extends Model implements HasMedia
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (! $model->created_by) {
|
||||
if (!$model->created_by) {
|
||||
$model->created_by = auth()->id();
|
||||
}
|
||||
});
|
||||
@@ -52,9 +52,9 @@ class Meetup extends Model implements HasMedia
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom(['name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
->generateSlugsFrom(['name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
@@ -64,16 +64,16 @@ class Meetup extends Model implements HasMedia
|
||||
->fit(Manipulations::FIT_CROP, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Manipulations::FIT_CROP, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
->fit(Manipulations::FIT_CROP, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('logo')
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
@@ -91,11 +91,6 @@ class Meetup extends Model implements HasMedia
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function meetupEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(MeetupEvent::class);
|
||||
}
|
||||
|
||||
protected function logoSquare(): Attribute
|
||||
{
|
||||
$media = $this->getFirstMedia('logo');
|
||||
@@ -106,7 +101,7 @@ class Meetup extends Model implements HasMedia
|
||||
}
|
||||
|
||||
return Attribute::make(
|
||||
get: fn () => url()->route('img',
|
||||
get: fn() => url()->route('img',
|
||||
[
|
||||
'path' => $path,
|
||||
'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/mailgun-mailer": "^6.2",
|
||||
"wesselperik/nova-status-field": "^2.1",
|
||||
"wireui/wireui": "dev-main",
|
||||
"wireui/wireui": "^1.17.9",
|
||||
"ziffmedia/nova-select-plus": "^2.0"
|
||||
},
|
||||
"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.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
|
||||
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",
|
||||
|
||||
@@ -72,11 +72,13 @@ Route::middleware([])
|
||||
return \App\Models\Meetup::query()
|
||||
->where('visible_on_map', true)
|
||||
->with([
|
||||
'city',
|
||||
'meetupEvents',
|
||||
'city.country',
|
||||
])
|
||||
->get()
|
||||
->map(fn($meetup) => [
|
||||
'name' => $meetup->name,
|
||||
'portalLink' => url()->route('meetup.landing', ['country' => $meetup->city->country, 'meetup' => $meetup]),
|
||||
'url' => $meetup->telegram_link ?? $meetup->webpage,
|
||||
'top' => $meetup->github_data['top'] ?? null,
|
||||
'left' => $meetup->github_data['left'] ?? null,
|
||||
@@ -87,6 +89,7 @@ Route::middleware([])
|
||||
'latitude' => (float)$meetup->city->latitude,
|
||||
'twitter_username' => $meetup->twitter_username,
|
||||
'website' => $meetup->webpage,
|
||||
'next_event' => $meetup->nextEvent,
|
||||
]);
|
||||
});
|
||||
Route::get('btc-map-communities', function () {
|
||||
|
||||
@@ -3428,13 +3428,6 @@ __metadata:
|
||||
languageName: node
|
||||
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":
|
||||
version: 4.0.0
|
||||
resolution: "js-tokens@npm:4.0.0"
|
||||
@@ -4932,7 +4925,6 @@ __metadata:
|
||||
"@tailwindcss/typography": ^0.5.0
|
||||
alpinejs: ^3.0.6
|
||||
autoprefixer: ^10.4.7
|
||||
js-confetti: ^0.11.0
|
||||
laravel-echo: ^1.15.0
|
||||
laravel-vite-plugin: ^0.7.2
|
||||
leaflet.heat: ^0.2.0
|
||||
|
||||
Reference in New Issue
Block a user