🎉 **Introduce meetup activity management**

- Added `is_active` and `last_event_at` fields to meetups with migration.
- Enhanced UI: Display `Aktiv`/`Inaktiv` badges and last event dates across dashboard, tables, and maps.
- Introduced `/meetups:update-activity` command to manage activity flags and timestamps.
- Validated latitude/longitude to prevent `0,0` inputs in city creation and updates.
- Updated factories and tests to include meetup activity states (`active`, `inactive`).
This commit is contained in:
HolgerHatGarKeineNode
2026-05-17 17:57:16 +02:00
parent bf9654de87
commit 71a4898303
16 changed files with 343 additions and 11 deletions
@@ -0,0 +1,64 @@
<?php
namespace App\Console\Commands\Database;
use App\Models\Meetup;
use App\Models\MeetupEvent;
use Carbon\CarbonInterface;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Date;
#[Signature('meetups:update-activity')]
#[Description('Recalculate is_active and last_event_at for every meetup based on its events.')]
class UpdateMeetupActivity extends Command
{
public function handle(): int
{
$threshold = now()->subYear();
Meetup::query()->chunkById(200, function ($meetups) use ($threshold) {
foreach ($meetups as $meetup) {
$this->updateMeetup($meetup, $threshold);
}
});
$this->info('Meetup activity flags updated.');
return Command::SUCCESS;
}
private function updateMeetup(Meetup $meetup, CarbonInterface $threshold): void
{
$lastEventAt = MeetupEvent::query()
->where('meetup_id', $meetup->id)
->where('start', '<=', now())
->max('start');
$lastEventAt = $lastEventAt ? Date::parse($lastEventAt) : null;
$hasFutureEvent = MeetupEvent::query()
->where('meetup_id', $meetup->id)
->where('start', '>', now())
->exists();
$hasActiveRecurrence = MeetupEvent::query()
->where('meetup_id', $meetup->id)
->whereNotNull('recurrence_type')
->where(function ($query) {
$query->whereNull('recurrence_end_date')
->orWhere('recurrence_end_date', '>=', now());
})
->exists();
$isActive = ($lastEventAt && $lastEventAt->greaterThanOrEqualTo($threshold))
|| $hasFutureEvent
|| $hasActiveRecurrence;
$meetup->forceFill([
'is_active' => $isActive,
'last_event_at' => $lastEventAt,
])->saveQuietly();
}
}
+4
View File
@@ -41,6 +41,8 @@ class Meetup extends Model implements HasMedia
'community',
'github_data',
'visible_on_map',
'is_active',
'last_event_at',
];
/**
@@ -53,6 +55,8 @@ class Meetup extends Model implements HasMedia
'city_id' => 'integer',
'github_data' => 'json',
'simplified_geojson' => 'array',
'is_active' => 'boolean',
'last_event_at' => 'datetime',
];
protected static function booted()